alternative approach cmd
This commit is contained in:
parent
d6aa8da2de
commit
51cbe87755
17
start.sh
17
start.sh
@ -46,12 +46,15 @@ stop_server() {
|
|||||||
start_server() {
|
start_server() {
|
||||||
if ! is_server_running; then
|
if ! is_server_running; then
|
||||||
log "Starting Node server..."
|
log "Starting Node server..."
|
||||||
# Start the server and connect stdin
|
# Start the server in foreground
|
||||||
npm run start < /dev/stdin &
|
npm run start &
|
||||||
|
NODE_PID=$!
|
||||||
sleep 2 # Wait for the server to start
|
sleep 2 # Wait for the server to start
|
||||||
|
|
||||||
if is_server_running; then
|
if is_server_running; then
|
||||||
log "Node server started successfully"
|
log "Node server started successfully"
|
||||||
|
# Bring the process to foreground
|
||||||
|
fg %1
|
||||||
else
|
else
|
||||||
log "ERROR: Failed to start Node server"
|
log "ERROR: Failed to start Node server"
|
||||||
exit 1
|
exit 1
|
||||||
@ -91,11 +94,5 @@ log "Database migrations completed successfully"
|
|||||||
start_server
|
start_server
|
||||||
|
|
||||||
# Monitor server and restart if it stops
|
# Monitor server and restart if it stops
|
||||||
log "Starting server monitoring..."
|
log "Server started. You can now interact with the Node.js console."
|
||||||
while true; do
|
wait $NODE_PID
|
||||||
if ! is_server_running; then
|
|
||||||
log "Server stopped unexpectedly. Restarting..."
|
|
||||||
start_server
|
|
||||||
fi
|
|
||||||
sleep 10 # Check every 10 seconds
|
|
||||||
done
|
|
Loading…
x
Reference in New Issue
Block a user