Fixed bugs with --config flag
This commit is contained in:
24
main.go
24
main.go
@@ -33,7 +33,12 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := LoadOrCreateConfig(*configFlag)
|
||||
absConfigPath, err := filepath.Abs(*configFlag)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to resolve absolute configuration path target: %v", err)
|
||||
}
|
||||
|
||||
cfg, err := LoadOrCreateConfig(absConfigPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Initialization failed: %v", err)
|
||||
}
|
||||
@@ -43,8 +48,8 @@ func main() {
|
||||
switch subCommand {
|
||||
|
||||
case "daemon":
|
||||
fmt.Println("Initializing VS server manager background supervisor...")
|
||||
if err := StartDaemon(cfg); err != nil {
|
||||
fmt.Printf("Initializing VS server manager background supervisor [Config: %s]...\n", absConfigPath)
|
||||
if err := StartDaemon(cfg, absConfigPath); err != nil {
|
||||
log.Fatalf("Daemon runtime fatal error: %v", err)
|
||||
}
|
||||
|
||||
@@ -71,7 +76,7 @@ func main() {
|
||||
sendIPCRequest(cfg, "POST", fmt.Sprintf("/instances/stop?name=%s", url.QueryEscape(name)), nil)
|
||||
|
||||
case "cmd":
|
||||
if len(args) < 4 {
|
||||
if len(args) < 3 {
|
||||
log.Fatalf("Usage: vssm cmd <instance_name> \"<server command>\"")
|
||||
}
|
||||
name := args[1]
|
||||
@@ -84,6 +89,9 @@ func main() {
|
||||
case "list", "status":
|
||||
fetchAndPrintStatus(cfg)
|
||||
|
||||
case "show-config":
|
||||
fmt.Printf("%v", cfg.Storage.AppDataDir)
|
||||
|
||||
default:
|
||||
printUsage()
|
||||
}
|
||||
@@ -107,7 +115,8 @@ func sendIPCRequest(cfg *AppConfig, method string, path string, body io.Reader)
|
||||
defer resp.Body.Close()
|
||||
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
||||
log.Fatalf("Error from daemon: %s", string(respBody))
|
||||
}
|
||||
|
||||
@@ -149,10 +158,13 @@ func fetchAndPrintStatus(cfg *AppConfig) {
|
||||
|
||||
func printUsage() {
|
||||
fmt.Println("VintageStory Server Manager")
|
||||
fmt.Println("\nUsage:")
|
||||
fmt.Println("\nGlobal Options:")
|
||||
fmt.Println(" --config <path> Explicitly target a non-default config structure file location")
|
||||
fmt.Println("\nUsage Commands:")
|
||||
fmt.Println(" vssm daemon Starts the background process supervisor")
|
||||
fmt.Println(" vssm create <name> <version> Provisions baseline configuration and stores instance profile")
|
||||
fmt.Println(" vssm start <name> Launches an existing server instance using stored profile")
|
||||
fmt.Println(" vssm stop <name> Gracefully shuts down a server instance")
|
||||
fmt.Println(" vssm cmd <name> \"<command>\" Dispatches a terminal console command down the pipe")
|
||||
fmt.Println(" vssm list Displays the operational matrix of all instances")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user