BlackHatSamurai
BlackHatSamurai

Reputation: 23503

Continuously run Sinatra on Apache server

Is it possible to ssh into a server, start a Ruby program with Sinatra, and then log out of the ssh session, and still have the Sinatra server run? I have tried this, but it seems that when I log out of the server, the Sinatra server quits. Am I doing something wrong? If I can't do this, how would I run Sinatra continuously?

Upvotes: 1

Views: 633

Answers (2)

kitofr
kitofr

Reputation: 761

You could also use gnu screen

But nohup is probably the "smallest thing that can possibly work". Screen can help out if you start multiple things and want to handle them differently.

Upvotes: 0

Casper
Casper

Reputation: 34328

This is usually due to the shell (for example bash) exiting and sending hangup or kill signals to all its child processes. To start the server in the background and shield it from the HUP signal you can use the command nohup:

    nohup - run a command immune to hangups, with output to a non-tty

For example:

nohup ruby sinatra_app.rb &

http://en.wikipedia.org/wiki/Nohup

For more robust deployment options you might want to look at something like Nginx and/or Phusion Passenger:

Robust way to deploy a Rack application (Sinatra)

Upvotes: 3

Related Questions