@@ -179,9 +179,19 @@ export const application = (
179179 log ( `Serve process spawned: pid=${ proc . pid } ` ) ;
180180
181181 if ( opts . detached ) {
182- proc . on ( 'exit' , ( code , signal ) => {
183- log ( `Serve process exited: code=${ code } , signal=${ signal } ` ) ;
184- } ) ;
182+ // Give the process a moment to start, then check its state
183+ await new Promise ( res => setTimeout ( res , 3000 ) ) ;
184+ try {
185+ const procExists = execSync ( `kill -0 ${ proc . pid } 2>&1 && echo "alive" || echo "dead"` , {
186+ encoding : 'utf-8' ,
187+ } ) . trim ( ) ;
188+ log ( `Serve process ${ proc . pid } status after 3s: ${ procExists } ` ) ;
189+ const ssOut = execSync ( `ss -tlnp 2>&1 | head -20 || true` , { encoding : 'utf-8' } ) ;
190+ log ( `Listening ports:\n${ ssOut } ` ) ;
191+ } catch {
192+ log ( 'Could not check serve process status' ) ;
193+ }
194+
185195 const shouldExit = ( ) => {
186196 if ( proc . exitCode != null ) {
187197 log ( `Serve process has exitCode=${ proc . exitCode } ` ) ;
@@ -192,25 +202,6 @@ export const application = (
192202 try {
193203 await waitForServer ( runtimeServerUrl , { log, maxAttempts : 120 , shouldExit } ) ;
194204 } catch ( e ) {
195- // Check what the serve process is actually doing
196- try {
197- const lsofOut = execSync ( `lsof -i -P -n -p ${ proc . pid } 2>&1 || true` , { encoding : 'utf-8' } ) ;
198- log ( `lsof for serve pid ${ proc . pid } :\n${ lsofOut || '(no output)' } ` ) ;
199- } catch {
200- log ( `Could not run lsof for pid ${ proc . pid } ` ) ;
201- }
202- try {
203- const psOut = execSync ( 'ps aux 2>&1 || true' , { encoding : 'utf-8' } ) ;
204- const serveLines = psOut
205- . split ( '\n' )
206- . filter (
207- l =>
208- l . includes ( String ( proc . pid ) ) || l . includes ( 'react-router' ) || l . includes ( 'vite' ) || l . includes ( String ( port ) ) ,
209- ) ;
210- log ( `Related processes:\n${ serveLines . join ( '\n' ) || '(none found)' } ` ) ;
211- } catch {
212- log ( 'Could not run ps' ) ;
213- }
214205 try {
215206 const stdoutContent = await fs . readFile ( stdoutFilePath , 'utf-8' ) ;
216207 const stderrContent = await fs . readFile ( stderrFilePath , 'utf-8' ) ;
0 commit comments