mirror of
https://github.com/Walter-Sparrow/lunar-tear.git
synced 2026-07-02 05:43:41 +03:00
Compare commits
3 Commits
f08e7a40c6
...
8abd5d007e
| Author | SHA1 | Date | |
|---|---|---|---|
| 8abd5d007e | |||
| 0c556563c6 | |||
| 7563087bef |
@@ -24,7 +24,13 @@ cd server
|
||||
go run ./cmd/wizard
|
||||
```
|
||||
|
||||
Your choices are saved so next time you just press Enter to relaunch with the same settings.
|
||||
Your choices are saved so next time you just press Enter to relaunch with the same settings. To skip the confirmation prompt entirely (useful for scripts or quick relaunches), pass `--prefer-saved`:
|
||||
|
||||
```bash
|
||||
go run ./cmd/wizard --prefer-saved
|
||||
```
|
||||
|
||||
If no saved config exists, the flag prints an error and exits.
|
||||
|
||||
#### Custom Ports
|
||||
|
||||
@@ -34,11 +40,12 @@ By default the wizard uses ports 8003 (gRPC), 8080 (CDN), and 3000 (auth). Overr
|
||||
go run ./cmd/wizard --grpc-port 9003 --cdn-port 9080
|
||||
```
|
||||
|
||||
| Flag | Default | Description |
|
||||
| ------------- | ------- | ---------------- |
|
||||
| `--grpc-port` | `8003` | gRPC server port |
|
||||
| `--cdn-port` | `8080` | CDN server port |
|
||||
| `--auth-port` | `3000` | Auth server port |
|
||||
| Flag | Default | Description |
|
||||
| ---------------- | ------- | ---------------------------------- |
|
||||
| `--prefer-saved` | `false` | Reuse saved config without prompting |
|
||||
| `--grpc-port` | `8003` | gRPC server port |
|
||||
| `--cdn-port` | `8080` | CDN server port |
|
||||
| `--auth-port` | `3000` | Auth server port |
|
||||
|
||||
Custom ports are saved to `.wizard.json` alongside your other settings. On the next run the saved ports are reused automatically — no need to pass the flags again. If you later pass different port flags, the wizard warns you that the ports changed and asks for confirmation before continuing.
|
||||
|
||||
|
||||
+1
-15
@@ -34,32 +34,18 @@ build-dev:
|
||||
go build -o bin/dev$(EXE) ./cmd/dev
|
||||
|
||||
build-all:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
if not exist bin mkdir bin
|
||||
else
|
||||
mkdir -p bin
|
||||
endif
|
||||
go build -o bin/dev$(EXE) ./cmd/dev
|
||||
go build -o bin/auth-server$(EXE) ./cmd/auth-server
|
||||
go build -o bin/octo-cdn$(EXE) ./cmd/octo-cdn
|
||||
go build -o bin/lunar-tear$(EXE) ./cmd/lunar-tear
|
||||
|
||||
clean:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
if exist bin rmdir /s /q bin
|
||||
else
|
||||
rm -rf bin
|
||||
endif
|
||||
rm -rf bin/*
|
||||
|
||||
dev:
|
||||
go run ./cmd/dev $(ARGS)
|
||||
|
||||
migrate:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
if not exist db mkdir db
|
||||
else
|
||||
mkdir -p db
|
||||
endif
|
||||
$(GOOSE) -dir migrations -allow-missing sqlite3 db/game.db up
|
||||
|
||||
import:
|
||||
|
||||
@@ -55,6 +55,7 @@ type ports struct {
|
||||
|
||||
func main() {
|
||||
setupOnly := flag.Bool("setup-only", false, "show patching instructions and exit without building or launching")
|
||||
preferSaved := flag.Bool("prefer-saved", false, "reuse saved config without prompting")
|
||||
grpcPort := flag.Int("grpc-port", defaultGRPCPort, "gRPC server port")
|
||||
cdnPort := flag.Int("cdn-port", defaultCDNPort, "CDN server port")
|
||||
authPort := flag.Int("auth-port", defaultAuthPort, "auth server port")
|
||||
@@ -77,7 +78,7 @@ func main() {
|
||||
downloadDeps()
|
||||
}
|
||||
|
||||
ip, cfg, firstRun := resolveIP()
|
||||
ip, cfg, firstRun := resolveIP(*preferSaved)
|
||||
|
||||
p := resolvePorts(flagSet, *grpcPort, *cdnPort, *authPort, cfg)
|
||||
savedPorts := portsFromConfig(cfg)
|
||||
@@ -289,7 +290,11 @@ func runProtoc() {
|
||||
|
||||
func runMigrate() {
|
||||
_ = spinner.New().Title(" Running migrations...").Action(func() {
|
||||
runQuiet(exec.Command(toolPaths["make"], "migrate", "GOOSE="+toolPaths["goose"]), "database migration")
|
||||
if err := os.MkdirAll("db", 0755); err != nil {
|
||||
fmt.Fprintf(os.Stderr, " Failed to create db/: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
runQuiet(exec.Command(toolPaths["goose"], "-dir", "migrations", "-allow-missing", "sqlite3", "db/game.db", "up"), "database migration")
|
||||
}).Run()
|
||||
}
|
||||
|
||||
@@ -311,12 +316,25 @@ func runQuiet(cmd *exec.Cmd, label string) {
|
||||
}
|
||||
}
|
||||
|
||||
func resolveIP() (string, config, bool) {
|
||||
if cfg, err := loadConfig(); err == nil {
|
||||
func resolveIP(preferSaved bool) (string, config, bool) {
|
||||
cfg, err := loadConfig()
|
||||
if err == nil {
|
||||
if preferSaved {
|
||||
if isLANBased(cfg) {
|
||||
if ip, updated, ok := recheckLANIP(cfg); ok {
|
||||
return ip, updated, false
|
||||
}
|
||||
}
|
||||
return cfg.IP, cfg, false
|
||||
}
|
||||
|
||||
ip, cfg, done := handleSavedConfig(cfg)
|
||||
if done {
|
||||
return ip, cfg, false
|
||||
}
|
||||
} else if preferSaved {
|
||||
fmt.Fprintln(os.Stderr, " --prefer-saved: no saved config found; run without the flag first.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
ip, cfg := runWizard()
|
||||
|
||||
Reference in New Issue
Block a user