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?
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.
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).
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With