alternative approach cmd

This commit is contained in:
Dennis Postma 2025-02-09 03:24:32 +01:00
parent d6aa8da2de
commit 51cbe87755

View File

@ -46,12 +46,15 @@ stop_server() {
start_server() {
if ! is_server_running; then
log "Starting Node server..."
# Start the server and connect stdin
npm run start < /dev/stdin &
# Start the server in foreground
npm run start &
NODE_PID=$!
sleep 2 # Wait for the server to start
if is_server_running; then
log "Node server started successfully"
# Bring the process to foreground
fg %1
else
log "ERROR: Failed to start Node server"
exit 1
@ -91,11 +94,5 @@ log "Database migrations completed successfully"
start_server
# Monitor server and restart if it stops
log "Starting server monitoring..."
while true; do
if ! is_server_running; then
log "Server stopped unexpectedly. Restarting..."
start_server
fi
sleep 10 # Check every 10 seconds
done
log "Server started. You can now interact with the Node.js console."
wait $NODE_PID