pids gone missing after the second 'thin start'

29 views
Skip to first unread message

Leon

unread,
Jan 28, 2008, 6:04:29 AM1/28/08
to thin-ruby
Hello,

Thanks for implementing thin! I am trying to deploy monit system to
monitor thin processes. I found when it did the second 'thin start',
the tmp/pids/thin.pid will be gone missing. Here is the reproducer:

# rails railstest
# cd railstest
# thin start -d
# ls tmp/pids/thin.pid
# thin start -d
# ls tmp/pids/thin.pid

Actual result:
tmp/pids/thin.pid gone missing

Expected result
tmp/pids/thin.pid exists and point to the process ID

Thanks,
Leon

macournoyer

unread,
Jan 28, 2008, 10:34:25 AM1/28/08
to thin-ruby
why do you start thin twice w/ the same options ?

Marc-André Cournoyer

unread,
Jan 29, 2008, 12:30:32 AM1/29/08
to Leon, thin...@googlegroups.com
can you provide the output of those commands.
I still don't understand how to reproduce

On 28-Jan-08, at 9:45 PM, Leon wrote:

> Hi,
>
> This is needed when one of the daemon dead off and required to restart
> again. Maybe this is a better example:
>
> # thin start -s 2 -d
> # ls -la tmp/pids/
> # kill -9 `cat tmp/pids/thin.3000.pid`
> # thin start -s 2 -d
> # ls -la tmp/pids/
>
> Cheers,
> Leon

Leon

unread,
Jan 29, 2008, 1:22:05 AM1/29/08
to thin-ruby
Sure!

# thin start -s 2 -d
Starting server on 0.0.0.0:3000 ...
Starting server on 0.0.0.0:3001 ...

# ls -la tmp/pids/
total 32
drwxr-xr-x 2 root root 4096 Jan 29 01:51 .
drwxr-xr-x 6 root root 4096 Jan 28 21:02 ..
-rw-r--r-- 1 root root 5 Jan 29 01:51 thin.3000.pid
-rw-r--r-- 1 root root 5 Jan 29 01:51 thin.3001.pid

# kill -9 `cat tmp/pids/thin.3000.pid`

# thin start -s 2 -d
Starting server on 0.0.0.0:3000 ...
Starting server on 0.0.0.0:3001 ...

# ls -la tmp/pids/
total 24
drwxr-xr-x 2 root root 4096 Jan 29 01:52 .
drwxr-xr-x 6 root root 4096 Jan 28 21:02 ..
-rw-r--r-- 1 root root 5 Jan 29 01:52 thin.3000.pid

Cheers,
Leon

On Jan 29, 1:30 pm, Marc-André Cournoyer <macourno...@gmail.com>
wrote:

macournoyer

unread,
Jan 29, 2008, 2:21:00 PM1/29/08
to thin-ruby
It's because you killed the server on port 3000, you need to send the
INT signal to stop the server gracefully, so it has time to remove its
PID file.

Then when you restarted it the second time it crashed because a server
was already listening on that port and the PID file was removed.

The correct way to stop the servers is through the stop command

thin stop -s 2

Let me know if this make sense to you, or tell me if you know how to
make this process more intuitive. One of Thin primary goal is ease of
use.

Thx for your help Leon

Leon

unread,
Jan 30, 2008, 2:24:06 AM1/30/08
to thin-ruby
Understood stop should be the correct way to stop the servers. I use
kill -9 to emulate when one of the servers is crashed without a
reason. The main problem is that monit brings up the server with start
command, not restart command. This is where I found the problem.

Anyway, I could also reproduce this problem with just two constructive
start command:
[root@localhost railstest]# thin start -s 2
Starting server on 0.0.0.0:3000 ...
Starting server on 0.0.0.0:3001 ...
[root@localhost railstest]# ls -al tmp/pids/
total 32
drwxr-xr-x 2 root root 4096 Jan 29 17:50 .
drwxr-xr-x 6 root root 4096 Jan 28 21:02 ..
-rw-r--r-- 1 root root 5 Jan 29 17:50 thin.3000.pid
-rw-r--r-- 1 root root 5 Jan 29 17:50 thin.3001.pid
[root@localhost railstest]# thin start -s 2
Starting server on 0.0.0.0:3000 ...
Starting server on 0.0.0.0:3001 ...
[root@localhost railstest]# ls -al tmp/pids/
total 16
drwxr-xr-x 2 root root 4096 Jan 29 17:50 .
drwxr-xr-x 6 root root 4096 Jan 28 21:02 ..

Just FYI on top of the previous test case.

Regards,
Leon

macournoyer

unread,
Jan 30, 2008, 10:28:44 AM1/30/08
to thin-ruby
aaah ok, I see the problem now!

I created a ticket for this: http://thin.lighthouseapp.com/projects/7212-thin/tickets/27

thx for reporting this Leon!
Reply all
Reply to author
Forward
0 new messages