@@ -10,6 +10,7 @@ import (
1010 "path/filepath"
1111 "strings"
1212
13+ "github.com/Vikrez22/phpvm/internal/ini"
1314 "github.com/Vikrez22/phpvm/internal/manifest"
1415 "github.com/Vikrez22/phpvm/internal/paths"
1516 "github.com/Vikrez22/phpvm/internal/resolver"
@@ -77,21 +78,23 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
7778 }
7879
7980 ps , _ := state .Load (m .ProjectRoot )
80- running := false
8181 webURL := ""
8282 dbURL := ""
83+ dbConfigured := m .Database != nil && m .Database .Engine != "" && m .Database .Engine != "none"
8384
8485 if ps != nil {
85- for name , pid := range ps .RunningPIDs {
86- if supervisor .IsProcessRunning (pid ) {
87- running = true
88- port := ps .AllocatedPorts [name ]
89- if name == "web" && port > 0 {
90- webURL = fmt .Sprintf ("http://127.0.0.1:%d" , port )
91- }
92- if name == "mysql" && port > 0 {
93- dbURL = fmt .Sprintf ("mysql://127.0.0.1:%d" , port )
94- }
86+ rt , _ := resolver .ResolveFromManifest (m )
87+ sup := supervisor .New (m , rt , ps )
88+ sup .CleanupStalePIDs ()
89+
90+ if pid := ps .RunningPIDs ["web" ]; pid != 0 && supervisor .IsProcessRunning (pid ) {
91+ if port := ps .AllocatedPorts ["web" ]; port > 0 {
92+ webURL = fmt .Sprintf ("http://127.0.0.1:%d" , port )
93+ }
94+ }
95+ if pid := ps .RunningPIDs ["mysql" ]; pid != 0 && supervisor .IsProcessRunning (pid ) {
96+ if port := ps .AllocatedPorts ["mysql" ]; port > 0 {
97+ dbURL = fmt .Sprintf ("mysql://127.0.0.1:%d" , port )
9598 }
9699 }
97100 }
@@ -104,11 +107,12 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
104107 json .NewEncoder (w ).Encode (map [string ]interface {}{
105108 "manifest_found" : true ,
106109 "project" : map [string ]interface {}{
107- "name" : name ,
108- "php" : m .Runtime .PHP ,
109- "web_url" : webURL ,
110- "db_url" : dbURL ,
111- "running" : running ,
110+ "name" : name ,
111+ "php" : m .Runtime .PHP ,
112+ "web_url" : webURL ,
113+ "db_url" : dbURL ,
114+ "db_configured" : dbConfigured ,
115+ "running" : webURL != "" || dbURL != "" ,
112116 },
113117 })
114118}
@@ -168,6 +172,12 @@ func handleUp(w http.ResponseWriter, r *http.Request) {
168172 json .NewEncoder (w ).Encode (map [string ]interface {}{"success" : false , "error" : err .Error ()})
169173 return
170174 }
175+ iniPath , err := ini .Generate (m .ProjectRoot , m , rt )
176+ if err != nil {
177+ json .NewEncoder (w ).Encode (map [string ]interface {}{"success" : false , "error" : err .Error ()})
178+ return
179+ }
180+ rt .PHPIniPath = iniPath
171181 ps , _ := state .Load (m .ProjectRoot )
172182 sup := supervisor .New (m , rt , ps )
173183 statuses , err := sup .Up (true , true )
0 commit comments