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

2

6

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.

Mendy answered 18/12, 2014 at 8:58 Comment(0)
M
3

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 &
Mendy answered 19/12, 2014 at 1:23 Comment(0)
M
2

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
Maleficent answered 18/12, 2014 at 11:5 Comment(1)
Tried n true™ with a few small sinatra 2.0 apps on my VPS. It works out of the box and let rack handle the webserver: i use (oh God i'm saying it publicly) webrick and the method above for any small app i deploy (capistrano).Hose

© 2022 - 2024 — McMap. All rights reserved.