Compare commits
2 Commits
e2ea472a10
...
22dde8c213
| Author | SHA1 | Date | |
|---|---|---|---|
| 22dde8c213 | |||
| 30463b60a5 |
26
TODO.md
26
TODO.md
@@ -1,16 +1,28 @@
|
||||
- [ ] Update check script:
|
||||
- [ ] Run `go fmt` on all .go files
|
||||
- [ ] Run prettier on all .ts files
|
||||
- [x] shellcheck on shell scripts
|
||||
- [x] `go vet` on go files
|
||||
- [x] `golangci-lint` on go files
|
||||
- [x] Run `go fmt` on all .go files
|
||||
- [ ] Eventually, run unit tests
|
||||
|
||||
- [ ] Adapt master program so that it reads configuration from command line
|
||||
- [x] Reimplement fixup.sh
|
||||
- [x] run shfmt on all shell scripts (and the files they `source`)
|
||||
- [x] Run `go fmt` on all .go files
|
||||
- [x] Run ~~prettier~~ biome on all .ts files and maybe others
|
||||
|
||||
|
||||
- [x] Adapt master program so that it reads configuration from command line
|
||||
args instead of from environment variables
|
||||
- Should have sane defaults
|
||||
- Adding new arguments should be easy and obvious
|
||||
|
||||
- [ ] Add wrapper script to run main program (so that various assumptions related
|
||||
- [x] Add wrapper script to run master program (so that various assumptions related
|
||||
to relative paths are safer)
|
||||
|
||||
- [ ] move `master-bin` into a subdir like `master/cmd` or whatever is
|
||||
idiomatic for golang programs; adapt `master` wrapper shell script
|
||||
accordingly
|
||||
|
||||
- [ ] Add unit tests all over the place.
|
||||
- ⚠️ Huge task - needs breakdown before starting
|
||||
|
||||
@@ -19,3 +31,9 @@
|
||||
- [ ] update framework-managed pnpm
|
||||
- [ ] update pnpm-managed deps
|
||||
- [ ] rebuild golang programs
|
||||
|
||||
- [ ] If the number of workers is large, then there is a long lapse between
|
||||
when you change a file and when the server responds
|
||||
- One solution: start and stop workers serially: stop one, restart it with new
|
||||
code; repeat
|
||||
- Slow start them: only start a few at first
|
||||
|
||||
2
master/.gitignore
vendored
2
master/.gitignore
vendored
@@ -1 +1 @@
|
||||
master
|
||||
master-bin
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module philologue.net/diachron/master
|
||||
module philologue.net/diachron/master-bin
|
||||
|
||||
go 1.23.3
|
||||
|
||||
|
||||
@@ -1,30 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
watchedDir := os.Getenv("WATCHED_DIR")
|
||||
watchDir := flag.String("watch", "../express", "directory to watch for changes")
|
||||
workers := flag.Int("workers", 1, "number of worker processes")
|
||||
basePort := flag.Int("base-port", 3000, "base port for worker processes")
|
||||
listenPort := flag.Int("port", 8080, "port for the reverse proxy to listen on")
|
||||
|
||||
numChildProcesses := 1
|
||||
if n, err := strconv.Atoi(os.Getenv("NUM_CHILD_PROCESSES")); err == nil && n > 0 {
|
||||
numChildProcesses = n
|
||||
}
|
||||
|
||||
basePort := 3000
|
||||
if p, err := strconv.Atoi(os.Getenv("BASE_PORT")); err == nil && p > 0 {
|
||||
basePort = p
|
||||
}
|
||||
|
||||
listenPort := 8080
|
||||
if p, err := strconv.Atoi(os.Getenv("LISTEN_PORT")); err == nil && p > 0 {
|
||||
listenPort = p
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
// Create worker pool
|
||||
pool := NewWorkerPool()
|
||||
@@ -35,12 +25,12 @@ func main() {
|
||||
|
||||
fileChanges := make(chan FileChange, 10)
|
||||
|
||||
go watchFiles(watchedDir, fileChanges)
|
||||
go watchFiles(*watchDir, fileChanges)
|
||||
|
||||
go runExpress(fileChanges, numChildProcesses, basePort, pool)
|
||||
go runExpress(fileChanges, *workers, *basePort, pool)
|
||||
|
||||
// Start the reverse proxy
|
||||
listenAddr := fmt.Sprintf(":%d", listenPort)
|
||||
listenAddr := fmt.Sprintf(":%d", *listenPort)
|
||||
go startProxy(listenAddr, pool)
|
||||
|
||||
// Wait for interrupt signal
|
||||
|
||||
8
master/master
Executable file
8
master/master
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
cd "$DIR"
|
||||
|
||||
./master-bin "$@"
|
||||
|
||||
Reference in New Issue
Block a user