8

In a remote CentOS VM Geddy application with MonogoDB wrapper is deployed. The application starts and listen to port 80 when below command is executed.

 geddy -e production &

The problem in this CLI command is when the SSH connection to VM was disconnected the process automatically gets closed. To make application working SSH needs to be opened always which is not possible. Is there any alternative method to keep it running as background service.

arvindwill
  • 1,960
  • 1
  • 23
  • 39
  • is any extra information required for negative marking? – arvindwill Mar 15 '17 at 08:00
  • General introduction for `daemon` computer program in `Unix` environment: https://en.wikipedia.org/wiki/Daemon_%28computing%29#Unix-like_systems There are the following options you have: use the OS infrastructure to run `services`. Integrate your project with the `services' infrastructure. For example Ubuntu have the ` service` command and you are able to do 'service MYPROG start', 'service MYPROG stop' and etc. The other possibilities are `nohup` or `GNU screen` (https://www.linode.com/docs/networking/ssh/using-gnu-screen-to-manage-persistent-terminal-sessions/) – zloster Mar 22 '17 at 08:23
  • But you will need extra custom scripts with `nohup` or `GNU screen` to assure that your application will start when the OS is restarted. – zloster Mar 22 '17 at 08:25
  • Current problem is not on restart, this while closing ssh connection. Even "nohup" command didnt helped. – arvindwill Mar 22 '17 at 16:37

1 Answers1

5

This happens because processes that are merely backgrounded will be sent a SIGHUP signal when their controlling terminal (the SSH connection) is closed.

The traditional method of preventing this is using the nohup utility:

nohup geddy -e production &

Alternatively, you can use terminal multiplexers like screen or tmux to create persistent terminal sessions (ones that remain active when you log out, and that can be reattached when you log in again at a later time).

robertklep
  • 198,204
  • 35
  • 394
  • 381