La aplicación NodeJS que se ejecuta en VPS (linux) falla cuando pongo mi computadora portátil a dormir
Frecuentes
Visto 575 veces
0
I absolutely 100% new to VPS and linux as of yesterday, and I'm running into an issue. Here's the process:
- I SSH into my VPS box in OSX terminal. The VPS is running CentOS 6 for what it's worth.
- I navigate to the correct folder and I run
node app.js
to launch my app inNodeJS
/ExpressJS
. - App launches and is readily accessible via the web at my VPS' ip address + the allocated port number.
- If I put my laptop to sleep, the app crashes and is no longer accessible via web.
Again, being new to Linux I'm not sure how to solve this problem. It makes sense, as the terminal that was running/taking logs of the node app is no longer responding, but what I'd like is:
a) To be able to start up the app remotely then have it just...run...forever, until I manually stop it b) To be able to SSH back into my server intermittently to check the logs, either via my mobile phone or my laptop.
Are either of these two things possible? Clearly my protocol of launching the app via terminal (as I'd normally do if running it locally) isn't the correct way to do it but I'm having trouble finding resources telling me what to do!
EDIT: I'm actually using Node Supervisor
to run the app which helps keep it up and running when things crash, not sure if that affects the situation.
1 Respuestas
2
Most probably your app is printing to standard out (the console), and that stream is closed/broken, when you put your laptop to sleep.
Hay al menos dos opciones:
Utilice la herramienta detectar: Sólo tipo
screen
before starting your app. Then start your app. Then Ctrl-A-D to detach from the screen. You can then safely log out from the VPS and put your laptop to sleep. To go back to the output of your app, log back in and typescreen -r
Run the app in the background:
node app.js &
.
respondido 27 nov., 13:05
Just to clarify, with
Screen
do I run it from OSX or from within my SSH connection to CentOS? - JVGFrom within your ssh connection on CentOS. - Christian Fritz