Advise on how to upgrade Thin from 0.6.2 to 0.6.4

56 views
Skip to first unread message

Dinooz

unread,
Feb 16, 2008, 3:42:12 PM2/16/08
to thin-ruby
My "gem list" command returns:
thin (0.6.4, 0.6.2, 0.6.1, 0.5.4, 0.5.3, 0.5.2, 0.5.0)

Until 0.6.2 everything used to be working fine... I create 2 shell
scripts to automatically start multiple instances of thin...

cat ./mystart.sh
cd /path/of/the/rails/app1/
./my_thin2.sh
echo ">> Thin App1 Started "
cd /path/of/the/rails/app2/
./my_thin2.sh
echo ">> Thin App2 Started "

Where the content in appX folder of the file my_thin2.sh is:
thin start -e production -p 6006 -s 1 -d

This works great until upgrade to version 0.6.4 seems like something
is not working quite right...

###################
Starting server on 0.0.0.0:6006 ...
/usr/local/lib/ruby/gems/1.8/gems/thin-0.6.4/lib/thin/daemonizing.rb:
39:in `daemonize': tmp/pids/thin.6006.pid already exist, seems like
it's already running. Stop the process or delete tmp/pids/thin.
6006.pid. (Thin::PidFileExist)
from /usr/local/lib/ruby/gems/1.8/gems/thin-0.6.4/lib/thin/
controllers/controller.rb:36:in `start'
from /usr/local/lib/ruby/gems/1.8/gems/thin-0.6.4/lib/thin/
runner.rb:143:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/thin-0.6.4/lib/thin/
runner.rb:143:in `run_command'
from /usr/local/lib/ruby/gems/1.8/gems/thin-0.6.4/lib/thin/
runner.rb:114:in `run!'
from /usr/local/lib/ruby/gems/1.8/gems/thin-0.6.4/bin/thin:6
from /usr/local/bin/thin:19:in `load'
from /usr/local/bin/thin:19

###################

I'm not sure why does not start properly but any adivse on make it
work will be really appreciated...

At this time I just uninstall 0.6.4 and everything works perfect.

Best Regards Dinooz.

PS => I notices is important to restart in my case Apache to make sure
the redirect works fine with all the new instances of Thin. Don't know
why the mod_proxy or the mod_redirect require this but once restarted
just works.

macournoyer

unread,
Feb 16, 2008, 10:39:43 PM2/16/08
to thin-ruby
Seems like the server is already running, you need to stop it first.
Previous versions didn't have that check. The pid file was erased and
it was impossible to use the stop command after.

Or check if the process is indeed running:

ps aux | grep thin

If it is and there's no PID file run, kill -INT <PID> then run your
command.

Let me know if this fixes your issue.

Dinooz

unread,
Feb 17, 2008, 11:42:06 AM2/17/08
to thin-ruby
It worked, I needed to delete the existing pid files located at:

/home/rails/rail_app1/tmp/pid/thin.6001.pid
/home/rails/rail_app2/tmp/pid/thin.6003.pid
/home/rails/rail_app3/tmp/pid/thin.6006.pid
/home/rails/rail_app4/tmp/pid/thin.6011.pid

Once I delete the previous PID's the start script worked just like
expected.

This will start 4 different RoR Applications.

########################################

I just need to figure it out why the stop command don't like the path
of the new PID's

$ ./stop_thins.sh

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

The stop_thisn.sh is a shell script with:

cd /home/rails/rails_app1/
/usr/local/bin/thin stop
echo ">> Rails_App1 << Stopped"

cd /home/rails/rails_app2/
/usr/local/bin/thin stop
echo ">> Rails_App2 << Stopped"

cd /home/rails/rails_app3/
/usr/local/bin/thin stop
echo ">> Rails_App3 << Stopped"

cd /home/rails/rails_app4/
/usr/local/bin/thin stop
echo ">> Rails_App4 << Stopped"

I just verify and the new PID files exist with the properly PID
number. I wonder if some extra parameter need to be passed to the "/
usr/local/bin/thin stop" command.

I also try manually to go in my shell to each particular path of the
rails_appx and execute the same command: "/usr/local/bin/thin stop"
with the same results.

Note: Yes the process R Running:

$ pstree -p |grep thin
|-thin(16124)
|-thin(16134)
|-thin(16147)
|-thin(16159)

Looking at the content of the new PID's:

$ cat gm/tmp/pids/thin.6011.pid
16134
$ cat gmt/tmp/pids/thin.6001.pid
16147
$ cat gt/tmp/pids/thin.6006.pid
16124
$ cat nca/tmp/pids/thin.6003.pid
16159

Keep doing the great job !!!. I noticed on this release did not have
to restart apache once I restart thin !!!.

Best Regards Din00z



chetanM

unread,
Feb 24, 2008, 5:44:31 AM2/24/08
to thin-ruby
#! /bin/bash

cd /app/current/

if [ "$1" == "start" ] ;then
echo "starting this cluster:"
thin start -d -p44556 -Ptmp/pids/thin-44556.pid -l log/thin.
44556.log
thin start -d -p44557 -Ptmp/pids/thin-44557.pid -l log/thin.
44557.log
thin start -d -p44558 -Ptmp/pids/thin-44558.pid -l log/thin.
44558.log

elif [ "$1" == "stop" ] ;then
echo "stoping the cluster:"
thin stop -Ptmp/pids/thin-44556.pid
thin stop -Ptmp/pids/thin-44557.pid
thin stop -Ptmp/pids/thin-44558.pid
else
echo "usage chthin start OORR chthin stop"
fi

echo "done"


then chmod to 777
use chthin start
chthin stop

have fun
chetanM

Dinooz

unread,
Feb 25, 2008, 2:25:04 PM2/25/08
to thin-ruby
Thank you ChetanM... check this out modified script to stop Thin
Cluster...

Cleaner Thin Stop Script create a file called my_stop.sh in the root
directory of your rails application.
####################
#!/bin/bash

this_path=`pwd`
pids_path="$this_path/tmp/pids/*.pid"

for thin_pid in $pids_path
do
echo "Stoping Thin Instance $thin_pid"
thin stop -P $thin_pid
done
####################

[dinooz@localhost rails_app1]$ cat my_thin2.sh
thin start -e development -p 3000 -s 3 -d

[dinooz@localhost rails_app1]$ ./my_thin2.sh
Starting server on 0.0.0.0:3000 ...
Starting server on 0.0.0.0:3001 ...
Starting server on 0.0.0.0:3002 ...

[dinooz@localhost rails_app1]$ ls tmp/pids/
thin.3000.pid thin.3001.pid thin.3002.pid

[dinooz@localhost rails_app1]$ pstree -p |grep thin
ââthin(780)
ââthin(784)
ââthin(788)

[dinooz@localhost rails_app1]$ cat tmp/pids/thin.3000.pid
780

[dinooz@localhost rails_app1]$ cat tmp/pids/thin.3001.pid
784

[dinooz@localhost rails_app1]$ cat tmp/pids/thin.3002.pid
788

[dinooz@localhost rails_app1]$ cat my_stop.sh
#!/bin/bash

this_path=`pwd`
pids_path="$this_path/tmp/pids/*.pid"

for thin_pid in $pids_path
do
echo "Stoping Thin Instance $thin_pid"
thin stop -P $thin_pid
done

[dinooz@localhost rails_app1]$ ./my_stop.sh
Stoping Thin Instance /home/dinooz/rails/rails_app1/tmp/pids/thin.
3000.pid
Sending QUIT signal to process 780 ...
Stoping Thin Instance /home/dinooz/rails/rails_app1/tmp/pids/thin.
3001.pid
Sending QUIT signal to process 784 ...
Stoping Thin Instance /home/dinooz/rails/rails_app1/tmp/pids/thin.
3002.pid
Sending QUIT signal to process 788 ...

[dinooz@localhost rails_app1]$ pstree -p |grep thin
[dinooz@localhost rails_app1]$ ls tmp/pids/
[dinooz@localhost rails_app1]$

All Thin Processes attached to that particular application have been
killed and the files removed.

PROS:
1.- No hard coded ports required to start or stop the Thin Cluster
Instances
2.- With a simple shell script can change directory to the particular
rails app and execute my_stop.sh

TODO:
1.- Create a [ /etc/thin/app1.cfg ... /etc/thin/app2.cfg ... ] where
each configuration file include the definition of the Thin Cluster.
then can be started with /etc/init.d/thin start this will read the
files located in [ /etc/thin/app1.cfg ... /etc/thin/app2.cfg .. ] and
start each of the instances for each of the rails applications.

Best Regards Din00z.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages