Geddy CLI closes on SSH drop
Asked Answered
H

1

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.

Hanlon answered 11/3, 2017 at 5:30 Comment(4)
is any extra information required for negative marking?Hanlon
General introduction for daemon computer program in Unix environment: 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 (linode.com/docs/networking/ssh/…)Bartko
But you will need extra custom scripts with nohup or GNU screen to assure that your application will start when the OS is restarted.Bartko
Current problem is not on restart, this while closing ssh connection. Even "nohup" command didnt helped.Hanlon
J
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).

Jodhpurs answered 15/3, 2017 at 9:0 Comment(5)
tried and didnt help :( . It close the application once ssh is closed.Hanlon
@Hanlon any clues left in nohup.out that may point towards a reason why it isn't working?Jodhpurs
nohup geddy -e production &> /dev/null < /dev/null &!Hanlon
Cant able to fine nohup.outHanlon
@Hanlon if you redirect stdout/stderr to /dev/null, nohup won't log anything. If you leave out &> /dev/null, the file should get created (and will contain the output that gets written to stdout/stderr).Jodhpurs

© 2022 - 2024 — McMap. All rights reserved.