Setting paths for log and pid files not working?

706 views
Skip to first unread message

Edmund

unread,
Jan 27, 2008, 8:46:27 AM1/27/08
to thin-ruby
Hi all,

I'm using Thin 0.6.1 from the gem. It's running fine (and fast!),
but it doesn't seem to let me specify the pid or log files properly
when using the thin start script. If I pass -P /var/run/thin.pid and
set debug on, the actual command run includes --pid "/u/apps/...(long
path name from Cap)/var/run/thin.pid. Same happens with logs. If I
create that path the pid/log files are created properly.

However, using the new socket option works fine - I can set that to /
var/run/thin/appname.sock and it works perfectly with one or more
sockets created in /var/run/thin.

Clearly, it's joining the pid and log filenames to the current
directory - setting chdir to "/" at the top of the script gives the
correct path names, but that breaks various other things. I can't see
where it's treating these options differently to the socket path.

Is anyone else getting this, or am I doing something really
obviously wrong here? Is it not intended to use an absolute path?

Also - which may be related - the thin stop option doesn't work with
a cluster, as it's looking for thin.pid rather than thin.x.pid.
Shouldn't it be looping through all thin.x.pids and stopping them?
(Specifying each one with -P works fine.)

--
Best regards,
Edmund

Kevin Williams

unread,
Jan 27, 2008, 10:37:59 AM1/27/08
to thin...@googlegroups.com
Hello Edmund,

There could be a few reasons why that may happen. Are you using the
Thin clustering option? Are you using the chdir option? Perhaps
posting your start and stop commands would help us diagnose the
problem.

I run with the unix socket option, like this:

thin start -d -e production -S /u/apps/blog/shared/pids/thin.1.sock -P
tmp/pids/thin.1.pid -c /u/apps/blog/current

This has no cluster and does use the chdir option.

Hope that helps.

--
Cheers,

Kevin Williams
http://www.bantamtech.com/
http://www.almostserio.us/
http://kevwil.com/

Edmund

unread,
Jan 27, 2008, 1:22:21 PM1/27/08
to thin-ruby
Hi Kevin,

> There could be a few reasons why that may happen. Are you using the
> Thin clustering option? Are you using the chdir option? Perhaps
> posting your start and stop commands would help us diagnose the
> problem.

OK, tell me if I'm doing something wrong anywhere.

My start command is:

thin start -e production -s 2 -S /var/run/thin.sock --pid /var/run/
thin.pid -l /var/log/thin.log -c /u/apps/blog -D

This produces the following:

Starting server on /var/run/thin.0.sock ...
thin start --environment="production" --pid="/u/apps/blog/var/run/thin.
0.pid" --chdir="/u/slate" --daemonize --timeout=60 --socket="/var/run/
thin.0.sock" --log="/u/apps/blog/var/log/thin.0.log"
Starting server on /var/run/thin.1.sock ...
thin start --environment="production" --pid="/u/apps/blog/var/run/thin.
1.pid" --chdir="/u/slate" --daemonize --timeout=60 --socket="/var/run/
thin.1.sock" --log="/u/apps/blog/var/log/thin.1.log"

It works, but notice that the pid and log files that thin actually
uses are not where I specified.

I tried running it without the cluster option and the same applies,
although rather than the Starting server on... messages, I get dozens
of lines of Exception `MissingSourceFile' for things I don't have
installed (this is with debug on.)

For stopping, I was referring to the default thin start for a
cluster. If you start with thin start -s 2 (which produces tmp/pids/
thin.3000.pid and /tmp/pids/thin.3001.pid), you can't use thin stop as
that looks for tmp/thin.pid and dies messily. It's probably a feature
request rather than problem - thin stop should look for thin.*.pid in
the default or specified path and stop them all.

... and now I've typed the word thin too many times and feel the
need to exercise. Thanks for your help, let me know if there's
anything else I can provide to makes sense of what I'm saying.

--
Best regards,
Edmund

macournoyer

unread,
Jan 27, 2008, 4:09:12 PM1/27/08
to thin-ruby
I think you just found a bug Edmund :)

You were not doing anything wrong. The path to the log and pid file
are concatenated to the chdir path, which is wrong, I opened a ticket
for that, I'll try to fix that for next release:
http://thin.lighthouseapp.com/projects/7212/tickets/24-absolute-path-to-log-and-pid-files-don-t-play-nice-with-chdir-option-in-cluster

In the meantime, you can specify a relative path for log and pid files
if you really wanna put it under /var, something like ../../../../
var/...
or place it under /u/apps/blog/log & /u/apps/blog/tmp/pids which is
the default.

thx for reporting!

Kevin Williams

unread,
Jan 27, 2008, 11:01:47 PM1/27/08
to thin...@googlegroups.com
"thin stop -s 2 -P tmp/pids/thin.pid" should stop a clustered server.
It needs both the # servers in cluster and the pid meta-location to
derive the actual pids from.

I must admit, the cluster support in thin is pretty slick, but I use
Monit to monitor not only my Thin processes but every other daemon on
my server. Monit can restart any mis-behaving daemon for me, so I
start Thin processes separately using Monit. As much as I like the
cluster support in Thin, may I suggest that you look at either Monit
or God to control your Thin cluster. You may find Thin is more
predictable when you start each process explicitly.

http://www.tildeslash.com/monit
http://god.rubyforge.org

--

macournoyer

unread,
Jan 28, 2008, 4:46:11 PM1/28/08
to thin-ruby
btw it's fixed on git

On Jan 27, 11:01 pm, "Kevin Williams" <kev...@gmail.com> wrote:
> "thin stop -s 2 -P tmp/pids/thin.pid" should stop a clustered server.
> It needs both the # servers in cluster and the pid meta-location to
> derive the actual pids from.
>
> I must admit, the cluster support in thin is pretty slick, but I use
> Monit to monitor not only my Thin processes but every other daemon on
> my server. Monit can restart any mis-behaving daemon for me, so I
> start Thin processes separately using Monit. As much as I like the
> cluster support in Thin, may I suggest that you look at either Monit
> or God to control your Thin cluster. You may find Thin is more
> predictable when you start each process explicitly.
>
> http://www.tildeslash.com/monithttp://god.rubyforge.org

Edmund

unread,
Jan 29, 2008, 6:43:16 PM1/29/08
to thin-ruby
Hi Kevin,

> "thin stop -s 2 -P tmp/pids/thin.pid" should stop a clustered server.
> It needs both the # servers in cluster and the pid meta-location to
> derive the actual pids from.

Ah, right. Fair enough - might be a nice touch to loop through and
stop any server pids it finds, but not that important.

> I must admit, the cluster support in thin is pretty slick, but I use
> Monit to monitor not only my Thin processes but every other daemon on
> my server. Monit can restart any mis-behaving daemon for me, so I
> start Thin processes separately using Monit. As much as I like the
> cluster support in Thin, may I suggest that you look at either Monit
> or God to control your Thin cluster. You may find Thin is more
> predictable when you start each process explicitly.

I never leave home without Monit (although I have been thinking
about switching to God for a bunch of new Rails servers), but I do
like to make sure new stuff works by hand before turning it over to
the machines!

--
Best regards,
Edmund

Edmund

unread,
Jan 29, 2008, 6:45:24 PM1/29/08
to thin-ruby
> btw it's fixed on git

Good stuff, thanks. Will let you know if I spot anything else.
Reply all
Reply to author
Forward
0 new messages