Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a Sinatra app as a deamon from the command line?

Tags:

sinatra

thin

How do I run a Sinatra app as a deamon from the command line?

It is using Thin:

ruby app.rb -p 3000 -e production

I don't like to set it up in the app.rb itself. I want to deamonise it from the command line.

like image 714
Paul Verschoor Avatar asked Dec 18 '14 08:12

Paul Verschoor


2 Answers

From Start Sinatra app in the background with stdout and stderr redirected (append) to a file:

nohup ruby app.rb -p 3000 -e production >> log/log_file 2>&1 &
like image 176
Paul Verschoor Avatar answered Sep 30 '22 00:09

Paul Verschoor


I don't know if it's possible with Ruby. But it's an easy task with rackup.

Just add a config.ru:

require './app'
run Sinatra::Application

And with this in place you can start it as a daemon:

rackup -p 3000 -E production -D
like image 26
Sir l33tname Avatar answered Sep 30 '22 01:09

Sir l33tname