List Info

Thread: bin/mongrel_rails to make it play nice with monit




bin/mongrel_rails to make it play nice with monit
country flaguser name
United States
2007-11-06 16:33:37
Looks like the mongrel_rails command in mongrel 1.1 still
does not fix
(or include an option) the issue of stale pid files. 
mongrel_rails
will just exit if a pid exists without first checking if
anything is
actually running.  You can use this script to patch up
mongrel_rails...

#===== patch mongrel
cd /usr/lib/ruby/gems/1.8/gems/mongrel-1.1/bin/
cp mongrel_rails mongrel_rails.orig
patch -p0 << 'EOF'
--- mongrel_rails	2007-05-08 11:18:32.000000000 -0500
+++ mongrel_rails.new	2007-05-08 11:18:32.000000000 -0500
 -83,10
+83,20 
       config =
Mongrel::Rails::RailsConfigurator.new(settings) do
         if defaults[:daemon]
           if File.exist? defaults[:pid_file]
-            log "!!! PID file #{defaults[:pid_file]}
already exists.
Mongrel could be running already.  Check your
#{defaults[:log_file]}
for errors."
-            log "!!! Exiting with error.  You must
stop mongrel and
clear the .pid before I'll attempt a start."
-            exit 1
+            pid = File.new(defaults[:pid_file]).readline
+            if `ps --pid # --no-headers`.length >
0
+                log "!!! PID file
#{defaults[:pid_file]} already
exists and the process id referenced is running.  This
mongrel is
probably already running.  #{defaults[:log_file]} for
errors.
EXITING."
+                exit 1
+            else
+                log "!!! PID file
#{defaults[:pid_file]} exists, but
is stale, and will be deleted so that this mongrel can
run."
+                File.delete(defaults[:pid_file])
+            end
           end
+#          if File.exist? defaults[:pid_file]
+#            log "!!! PID file #{defaults[:pid_file]}
already
exists.  Mongrel could be running already.  Check your
#{defaults[:log_file]} for errors."
+#            log "!!! Exiting with error.  You must
stop mongrel and
clear the .pid before I'll attempt a start."
+#            exit 1
+#          end

           daemonize
           log "Daemonized, any open files are closed. 
Look at
#{defaults[:pid_file]} and #{defaults[:log_file]} for
info."
EOF


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talkgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: bin/mongrel_rails to make it play nice with monit
user name
2007-11-06 18:33:06
On Nov 6, 2007 5:33 PM, uncle < aktxyzgmail.com">aktxyzgmail.com> wrote:

Looks like the mongrel_rails command in mongrel 1.1 still does not fix
(or include an option) the issue of stale pid files.  mongrel_rails
will just exit if a pid exists without first checking if anything is
actually running.  You can use this script to patch up
mongrel_rails...
&lt;snip>

Maybe it's specific to mongrel_cluster, but I thought there was a new --clean option to take care of this.

Michael Guterl

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talkgooglegroups.com
To unsubscribe from this group, send email to rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )