Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thin::Server#daemonize exits immediately

Tags:

ruby

sinatra

thin

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?

like image 623
benzimmer Avatar asked Jul 24 '12 09:07

benzimmer


People also ask

What is a thin server?

In the computer industry, a thin server is a PC that contains just enough hardware and software to support a particular function that users can share in a network, such as access to files on a storage device, access to CD-ROM drives, printing, or Internet access.

Can a thin client be used as a server?

A thin client connects to a server-based environment that hosts the majority of applications, memory, and sensitive data the user needs. Thin clients can also connect to servers based in the cloud. In many instances, a thin client computer is an effective replacement for a personal computer (PC).

How does thin client connect to server?

A thin-client device uses one of three protocols to communicate with the server: Independent Computing Architecture (ICA), Remote Desktop Protocol (RDP), or X. These protocols transfer display information from the server to the client, and keyboard and mouse input from the client to the server.

What is thin Ruby?

Thin is a Ruby web server that glues together 3 of the best Ruby libraries in web history: The Mongrel parser: the root of Mongrel speed and security.


1 Answers

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
like image 72
matt Avatar answered Oct 11 '22 13:10

matt