Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't keep my server running once I close terminal or my ssh session

I have never set up a server before but since Parse announced that they are closing down I thought I might give it a shot. I have followed along with this tutorial and have managed to migrate my Parse database across to digital ocean.

When I call npm run start everything works fine. I can query for data and create new objects all from my iOS app. But there is just one problem. How do I keep the server up and running even when terminal is not running from my Mac.

When I call npm run start this is what gets logged in terminal:

> [email protected] start /var/www/parse
> node index.js

[TypeError: Cannot read property 'Kerberos' of undefined]
DATABASE_URI not specified, falling back to localhost.
parse-server-example running on port 1337.

I know that this is probably a noob question and yes my knowledge is quite limited, so if you could help me then that would be great!

Thanks for your time!

like image 318
Shayno Avatar asked Feb 07 '16 23:02

Shayno


People also ask

Why does SSH keep disconnecting?

This is usually the result of a packet filter or NAT device timing out your TCP connection due to inactivity. For security, reason most enterprises only use SSH protocol version 2. This problem only occurred with version 2.

Which command keep processes running even after exiting the shell?

One of them is to use the disown command. It tells your shell to refrain from sending a HUP (hangup) signal to the process when you log off. So, the process continues running. This can be very handy whenever you start a process, and then for some reason you can't stay logged in and wait until it finishes.


2 Answers

Okay so I have just found the answer after posting a question on the Digital Ocean question page, instead of running npm run start I should have been doing nohup npm start &

like image 147
Shayno Avatar answered Oct 09 '22 21:10

Shayno


  1. use screen to create a new session https://tournasdimitrios1.wordpress.com/2010/11/04/linux-the-screen-command-a-must-for-ssh/
  2. start your server
  3. detach session
  4. return to running session when needed
like image 32
Lev Avatar answered Oct 09 '22 21:10

Lev