Thin and sinatra - how to stop/restart? No thin.pid
Asked Answered
T

1

6

I'm using thin as the server for my Sinatra app. It is started thusly:

thin -C config/environment.yml -R config/config.ru start

Where environment.yml has thin stuff and config.ru has general stuff you'd find in a rackup file.

I would like to be able to daemonize (easy enough with thin's config file) and stop and restart this much like one does with apache/tomcat/etc.

When I try thin stop or restart or various other things, I get:

Can't stop process, no PID found in tmp/pids/thin.pid

Indeed, there is no such file. I have tried specifying a pid file and location (ex. /tmp/thin.pid, to be easy) in the thin configuration yml to various different places. All this does is change the location of the directory in the "no PID found in" message, still no pid file is created.

Any ideas?

Trichloromethane answered 17/10, 2011 at 21:31 Comment(6)
Is your app really running? Do you get thin with ps ax | grep thin?Carbolated
Yes, the app is running, I get it with ps and I can connect to it via the browser/curl/what have you. I run it currently in a screen and, when I want to restart, simply screen -r, ctrl+c, and restart manually. I would like to do better.Trichloromethane
Have you tried thin -C config/environment.yml stop?Carbolated
I have, and I get that message. The only difference between thin stop and thin -C whatever.yml stop is the location of the directory where it's meant to be looking for pids. With the yaml file specified, it will look in the directory specified by the pid: option in that file. But either way, no pid file is ever written anywhere, as far as I can tell, by thin. I've tried adjusting the location, permissions, etc. No luck.Trichloromethane
from your question I guess you have daemonize option in you config file. But how about specifying --daemonize switch too?Carbolated
I swear it wasn't working before, but now it is. I had tried both with and without daemonize set to true. Now it works, only when daemonize is true. That means I need to get my logging in order quicker than I was going to, but that's fine. Submit it as an answer and I'll accept. Cheers!Trichloromethane
C
9

Pid will be created when thin is daemonized, so double-check your config for daemonize: true option. Considering that it's yaml, whitespace can make things go wrong. Alternatively specify --daemonize switch.

If location of your pid file is non-default, you should also specify config file when issuing stop:

thin -C config/environment.yml stop
Carbolated answered 21/10, 2011 at 10:37 Comment(1)
I'm pretty sure that this should be daemonize: true in the config file (i.e. no "d")Jung

© 2022 - 2024 — McMap. All rights reserved.