After quite a bit of searching and coding, I customized an init.d/bash script which allows me to manage multiple instances of Lighttpd server running Rails. It targets the specific PID address instead of the default binary location when starting and stopping /usr/local/bin/lighttpd process. This provides the ability in my case to have multiple lighttpd.conf files running many different instances and be able to restart each without disturbing the next. You can find the script at http://www.nshb.net/lighttpd-restart-script.html. Comments are welcome. Regards, Nathaniel. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nathaniel S. H. Brown http://nshb.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Dec 17, 2005, at 5:58 AM, Nathaniel S. H. Brown wrote:> After quite a bit of searching and coding, I customized an init.d/bash > script which allows me to manage multiple instances of Lighttpd server > running Rails. > > It targets the specific PID address instead of the default binary > location > when starting and stopping /usr/local/bin/lighttpd process. > > This provides the ability in my case to have multiple lighttpd.conf > files > running many different instances and be able to restart each without > disturbing the next. > > You can find the script at http://www.nshb.net/lighttpd-restart- > script.html. > Comments are welcome. > > Regards, > Nathaniel. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Nathaniel S. H. Brown http://nshb.netCool. Thanks Nathaniel. I will check this one out. Will it let you restart your fcgi''s without restarting lighttpd? Cheers- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Ezra Zygmuntowicz wrote:> > On Dec 17, 2005, at 5:58 AM, Nathaniel S. H. Brown wrote: > >> After quite a bit of searching and coding, I customized an init.d/bash >> script which allows me to manage multiple instances of Lighttpd server >> running Rails. >> >> It targets the specific PID address instead of the default binary >> location >> when starting and stopping /usr/local/bin/lighttpd process. >> >> This provides the ability in my case to have multiple lighttpd.conf files >> running many different instances and be able to restart each without >> disturbing the next. >> >> You can find the script at >> http://www.nshb.net/lighttpd-restart-script.html. >> Comments are welcome. > > Cool. Thanks Nathaniel. I will check this one out.Actually, I''ve been wondering about this. I''ve seen a number of posts recently about ways to restart Lighttpd and I''m not sure why that''s the case. How often are people changing their lighttpd.conf files? Is this a Windows thing that I''m just not seeing under Mac OS X and Linux?> Will it let you restart your fcgi''s without restarting lighttpd?This is what script/process/reaper is for. It''s pretty much the only thing I''ve used since it came out in 0.14.1/0.14.2 and it''s awesome. Plus, if you can configure your lighttpd to start as your user, then you can do script/process/reaper without needing sudo. -Brian
After reading this how-to, http://wiki.rubyonrails.com/rails/pages/LighttpdWithProcessScripts. You will find that by running the script/server and spinner/spawner instances that it runs a single instance for that process. My server runs many domains, and requires each to have their own instance of the lighttpd being able to be managed without disturbing the next. The lighttpd.sh script that was included with the lighttpd 1.3.7 package when ran, starts the instance itself, but when I ran stop, it would kill all processes matching the /usr/local/bin/lighttpd binary. This package solves that by specifically addressing the PID file associated to the lighttpd instance for that configuration file. In addition, the script that I have created can be placed in the /etc/init.d/ or rc.d directory and will be ran on boot time of the server, or manually managed by running the (start|stop|restart|reload|status) options on the script. David Gibbons had mentioned on his blog about using the @restart flag within the cron entry to manage the lighttpd instance. This will work well for starting the lighttpd server on reboot. But what happens if someone decides to killall -9 all the /usr/bin/local/lighttpd processes by accident? In such a case to ensure that your server is always running, you want to be able to probe the lighttpd instance itself, and be able to ensure that it is always up, you can do so by running the bin/lighttd.sh script every 5 minutes which will check to ensure the process is alive by checking the pid file and running a focused process status, and if the server is not running already it will start it for you. Such as putting this in your crontab file. */5 * * * * /home/httpd/vhosts/example.com/lighttpd/bin/lighttpd.sh start >/dev/null 2>&1 In addition to this bash script, I have just completed a full lighttpd-package template which I use to deploy my lighttpd installs on my system. And have made it available at http://nshb.net/lighttpd-package.html Regards, Nathaniel. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nathaniel S. H. Brown http://nshb.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> -----Original Message----- > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > Brian V. Hughes > Sent: December 17, 2005 1:17 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails] Lighttpd Restart Script > > Ezra Zygmuntowicz wrote: > > > > On Dec 17, 2005, at 5:58 AM, Nathaniel S. H. Brown wrote: > > > >> After quite a bit of searching and coding, I customized an > >> init.d/bash script which allows me to manage multiple instances of > >> Lighttpd server running Rails. > >> > >> It targets the specific PID address instead of the default binary > >> location when starting and stopping > /usr/local/bin/lighttpd process. > >> > >> This provides the ability in my case to have multiple > lighttpd.conf > >> files running many different instances and be able to restart each > >> without disturbing the next. > >> > >> You can find the script at > >> http://www.nshb.net/lighttpd-restart-script.html. > >> Comments are welcome. > > > > Cool. Thanks Nathaniel. I will check this one out. > > Actually, I''ve been wondering about this. I''ve seen a number > of posts recently about ways to restart Lighttpd and I''m not > sure why that''s the case. How often are people changing their > lighttpd.conf files? Is this a Windows thing that I''m just > not seeing under Mac OS X and Linux? > > > Will it let you restart your fcgi''s without restarting lighttpd? > > This is what script/process/reaper is for. It''s pretty much > the only thing I''ve used since it came out in 0.14.1/0.14.2 > and it''s awesome. Plus, if you can configure your lighttpd to > start as your user, then you can do script/process/reaper > without needing sudo. > > -Brian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Nathaniel S. H. Brown wrote:> After reading this how-to, > http://wiki.rubyonrails.com/rails/pages/LighttpdWithProcessScripts. > > You will find that by running the script/server and spinner/spawner > instances that it runs a single instance for that process.I didn''t say anything about spinner and spawner. In fact, the stuff I''ve read seems to indicate that spinner/spawner are meant to be used with scripttower deployments. I was talking about the reaper command for restarting the FastCGI listeners that control your app. Lighttpd is really just a HTTP reverse proxy for the application, if it''s run by FastCGI/SCGI.> My server runs many domains, and requires each to have their own instance of > the lighttpd being able to be managed without disturbing the next.No problem. That''s not only easy to do, it''s one of the preferred ways that Lighttpd should be run, based on the stuff I''ve read. (I don''t claim to be a Lighttpd expert)> The lighttpd.sh script that was included with the lighttpd 1.3.7 package when > ran, starts the instance itself, but when I ran stop, it would kill all > processes matching the /usr/local/bin/lighttpd binary. This package solves > that by specifically addressing the PID file associated to the lighttpd > instance for that configuration file.My question is why are you starting and stopping the specific Lighttpd process, when there''s a better way to restart/reload your Rails application? Are you, in fact, making new changes to the lighttpd.conf file each time you start and stop Lighttpd? If not, then I don''t understand why you are bouncing that process.> In addition, the script that I have created can be placed in the > /etc/init.d/ or rc.d directory and will be ran on boot time of the server, > or manually managed by running the (start|stop|restart|reload|status) > options on the script.Having startups automatically happen is a good thing. But all you really need is something that calls Lighttpd with the specific .conf file for your app/domain/virtual host. Right? Am I missing something?> David Gibbons had mentioned on his blog about using the @restart flag within > the cron entry to manage the lighttpd instance. This will work well for > starting the lighttpd server on reboot. But what happens if someone decides > to killall -9 all the /usr/bin/local/lighttpd processes by accident?If that last statement is indicative of what can happen on the production server that hosts your Rails apps, I''m really sorry to hear that. I guess, whatever you need to do to try and operate under those potential conditions is necessary.> In such a case to ensure that your server is always running, you want to be > able to probe the lighttpd instance itself, and be able to ensure that it is > always up, you can do so by running the bin/lighttd.sh script every 5 > minutes which will check to ensure the process is alive by checking the pid > file and running a focused process status, and if the server is not running > already it will start it for you. > > Such as putting this in your crontab file. > > */5 * * * * /home/httpd/vhosts/example.com/lighttpd/bin/lighttpd.sh > start >/dev/null 2>&1Like I said. If there''s a possibility that someone with root access on your server would "accidentally" kill -9 just the Lighttpd processes, whatever you need to do to keep them running is fine by me. I would be looking for another server admin, or a new hosting service, rather than trying to deal with that level of potential accident.> In addition to this bash script, I have just completed a full > lighttpd-package template which I use to deploy my lighttpd installs on my > system. And have made it available at http://nshb.net/lighttpd-package.htmlSounds good. I will most likely take a look, as I like to learn from those with more experience than me in the systems that run my applications/services. However, I''ve been running Lighttpd on my OS X Tiger server and I''ve never had a case where the Lighttpd process was accidentally killed (at least, not a case that didn''t coincide with a building/campus wide power outage that lasted longer than our UPS''s. For those not in the extreme situation as Nathaniel, please quit mucking with your Lighttpd processes if you aren''t making changes to the associated conf file that you need to enable. Use reaper to reload your Rails app code and reset the page caches. Based on what I''ve read and how I''ve seen it used, that''s was reaper was built for... -Brian -- Brian V. Hughes Associate Director for Web Operations (aka. Webmaster) Computing Technical Services Dartmouth College http://www.dartmouth.edu/comp/
On 12/17/05 Brian V. Hughes wrote:>Nathaniel S. H. Brown wrote: >> After reading this how-to, >> http://wiki.rubyonrails.com/rails/pages/LighttpdWithProcessScripts. >> >> You will find that by running the script/server and spinner/spawner >> instances that it runs a single instance for that process. > > I didn''t say anything about spinner and spawner. In fact, the stuff > I''ve read seems to indicate that spinner/spawner are meant to be used > with scripttower deployments. I was talking about the reaper command > for restarting the FastCGI listeners that control your app. Lighttpd > is really just a HTTP reverse proxy for the application, if it''s run > by FastCGI/SCGI.Sorry, I meant Switchtower, not Scripttower. See, told you I wasn''t an expert, yet. :) -Brian
Nathaniel, Thanks for the script! After months of fiddling around with this I finally found what I was looking for. The only thing I modified from your script was adding a DOMAIN line so I can multiply/modify the script easier and I also added a binary variable for sleep. Here are my mods: # Binary Paths CAT="/bin/cat" PS="/bin/ps" *SLEEP="/bin/sleep"* HTTPD="/usr/local/sbin/lighttpd" # Modifiy this line for each install *DOMAIN="xyz.abc.com"* PATH="/home/abc/domains/"*$DOMAIN*"/run/" LIGHTTPD_CONF=$PATH"lighttpd.conf" PIDFILE=$PATH"lighttpd.pid" Thanks again, Adrian Madrid HyperX Inc. Mobile: 801.815.1870 Office: 801.566.0670 aemadrid-kSB444ljgzMmlAP/+Wk3EA@public.gmane.org www.hyperxmedia.com 9000 S. 45 W. Sandy, UT 84070 Nathaniel S. H. Brown wrote:> After quite a bit of searching and coding, I customized an init.d/bash > script which allows me to manage multiple instances of Lighttpd server > running Rails. > > It targets the specific PID address instead of the default binary location > when starting and stopping /usr/local/bin/lighttpd process. > > This provides the ability in my case to have multiple lighttpd.conf files > running many different instances and be able to restart each without > disturbing the next. > > You can find the script at http://www.nshb.net/lighttpd-restart-script.html. > Comments are welcome. > > Regards, > Nathaniel. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Nathaniel S. H. Brown http://nshb.net > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails