Thin :: Server # daemonize exits immediately

I am trying to make an executable that launches a Sinatra application through Thin as a daemon. I use this code to call Thin using 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 that I get when I execute the script:

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

The server starts working fine when I do

 server.start 

Any suggestions as I track why it comes out immediately?

+6
source share
1 answer

Using daemonize only makes the daemon script, it does not actually start the server. You still need to call start after:

 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 
+4
source

Source: https://habr.com/ru/post/921187/


All Articles