Thin::Server#daemonize exits immediately
Asked Answered
I

1

6

I trying to make an executable, which starts a Sinatra application via Thin as a daemon. I am using this code to invoke Thin with the Sinatra app:

#!/usr/bin/env ruby

require 'thin'
require 'app.rb'

server = ::Thin::Server.new('127.0.0.1', 9999, App)
server.log_file = 'tmp/thin.log'
server.pid_file = 'tmp/thin.pid'
server.daemonize

Here is the log output I get when I execute the script:

>> Writing PID to tmp/thin.pid
>> Exiting!

The server starts fine when I do

server.start

Any suggestions how I track down why it exits immediately?

Infinitive answered 24/7, 2012 at 9:34 Comment(1)
1. Is tmp folder writable? 2. App or App.new in the server object creation part?Xanthate
O
4

Using daemonize only makes the script a daemon, it doesn’t actually start the server. You still need to call start afterwards:

server.daemonize
server.start

Log file:

>> Writing PID to tmp/thin.pid
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 127.0.0.1:9999, CTRL+C to stop
Overture answered 12/8, 2012 at 19:7 Comment(1)
This is quite a old post , but i did not have to start thin explicitly after calling server.daemonizeScholiast

© 2022 - 2024 — McMap. All rights reserved.