Renaming to vssm and adding a readme

This commit is contained in:
2026-06-05 19:39:32 -05:00
parent 8e575cab6e
commit ba5dd4f1ca
6 changed files with 112 additions and 45 deletions

View File

@@ -41,9 +41,22 @@ func StartDaemon(cfg *AppConfig) error {
mux.HandleFunc("/instances/command", ds.handleCommand)
mux.HandleFunc("/instances/list", ds.handleList)
corsWrappedHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusOK)
return
}
mux.ServeHTTP(w, r)
})
server := &http.Server{
Addr: cfg.Daemon.ListenAddress,
Handler: mux,
Handler: corsWrappedHandler,
}
sigChan := make(chan os.Signal, 1)
@@ -58,8 +71,10 @@ func StartDaemon(cfg *AppConfig) error {
<-sigChan
fmt.Println("\n[Daemon] Shutdown signal caught! Initializing graceful teardown sequence...")
_ = server.Close()
ds.shutdownAllRunningServers()
fmt.Println("[Daemon] All threads gracefully shut down. Exiting supervisor cleanly.")
return nil
}
@@ -185,7 +200,14 @@ func (ds *DaemonServer) handleStart(w http.ResponseWriter, r *http.Request) {
return
}
err := ds.procManager.StartInstance(name, options.Version, options, ds.cfg)
instanceConfigPath := filepath.Join(ds.cfg.Storage.InstancesDir, name, "serverconfig.json")
err := SyncInstanceConfig(options.Version, instanceConfigPath, options, ds.cfg)
if err != nil {
http.Error(w, "Failed to sync config: "+err.Error(), http.StatusInternalServerError)
return
}
err = ds.procManager.StartInstance(name, options.Version, options, ds.cfg)
if err != nil {
http.Error(w, fmt.Sprintf("Process startup failed: %v", err), http.StatusInternalServerError)
return