I am trying to run a nodejs server in a background process in a machine which I ssh into.
I use nohup node app.js &. However if my ssh connection times out the app also stops running in the background. Is there a way to keep the node server continuously running even after the timeout.
Related
I have a raspberry PI on which I run a node server. To start and control the terminal on which the server runs I use desktop remote to remote control the raspberry. Now this method is really slow so I was wondering, since I only need a command line anyway if I couldn't just connect to my raspberry pi using ssh for example.
My question now, would be if I do so, can I navigate to my node folder, run my node file and then close the ssh connection? Will my Node server keep running and if so how would I access the terminal with the node session after closing the connection?
The easiest way to do this is something like:
nohup node myapp.js &
This will make the app run in the background, and nohup prevents it from stopping when the connection closes.
This is a cheap and quick way to do this. A more appropriate way might be one of the following:
Using something like docker to manage running applications.
Using something like supervisord to do the same thing.
Writing scripts for initd and turn it into a real 'service'.
Changing the node application to fork & deamonize itself.
I am running a Node.js server on a DigitalOcean droplet (with Ubuntu). I have worked out how to make it run when I'm not connected to it via Putty. However, just one issue: how do I stop it now?
I can see that control+C works when in the session, but what if I exit the session and come back? How will I stop the server then?
Also, will running it multiple times run multiple servers at once?
Thanks!
You really should be using a tool like supervisord (http://supervisord.org/) for your long-running processes.
But if you want to stop an already running process that you started with nohup then look up the process ID first (with ps aux and look/grep for your process) and then run kill <<pid>>.
I recently deployed a node js server using forever running it as a debian server, simply using the command ' forever start app.js' . Is that safe for my hardware? I mean If a lot of requests get pulled in and my computer won't be able to handle them will forever stop preventing damage that would have occured if computer got too hot?
I want to run Derby in network mode on my virtual private server. I can connect to my server by ssh, execute
java -jar derbyrun.jar server start -noSecurityManager
and the network server starts succesfully as expected. However when I close the ssh connection that inevitably also shuts down Derby. Is there a way to start Derby without leaving the command prompt stuck, so that I can disconnect from my server and leave it running?
Perhaps
nohup java -jar derbyrun.jar server start -noSecurityManager &
would work?
I've a graphical program who has launched inside of the Front-End session.
I want to restart this application from putty, I can stop it by kill but I'm not be able to start application inside of the Front-End session.
When I Call application I get this error : cannot connect to X server
This may be way too late, but you can do it with these steps.
xhost +localhost
export DISPLAY=:0
restart_your_app_here
xhost command ensures your X server will take connections from the localhost.
export tells the X server where to send the X traffic (which is its own localhost).
Third command just restarts your app, you may want to do this in a tmux or screen so that the session doesn't get killed when you log out or get disconnected.