Hi all , i have writting my little node js file that run mysql querys for me what i need to know is how i keep this running when i am not connected as it will need to do this when i am not at the computer
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Greetings!
There are several ways to go about this. The dirtiest way (in my opinion) is simple but not fault tolerant, and it uses a screen session. So, for example, if this were Debian/Ubuntu:
apt-get update
apt-get install screen -y
screen -S nodeapp
node app.js
Then CTRL+A followed by CTRL+D to detach from the screen session. This persists when you log out of your SSH session.
However, I recommend something a bit more powerful if you’re up for it. You can use PM2 as a manager for this, and we have a tutorial here:
Obviously you don’t need all of that tutorial, but you should be able to extract what is relevant to you.
Jarland
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.