I have a sinatra app which I run on my local machine using ruby app.rb
.
While deploying it on a remote machine via ssh, How do i run it in background and redirect stdout and stderr to a log file. On a restart, I want to preserve the previous logs so that newer messages are appended to the existing log file, instead of truncating it.
What’s the recommended way of running my webapp as a daemon ?
I’ve tried nohup ruby app.rb &
, but that seems to be missing stderr and the log statements seem to be out of order in some cases.
Under bash, try:
ruby app.rb >> /log/file 2>&1 &
Check more discussion of this question.