<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TikiRobot! &#187; lighttpd</title>
	<atom:link href="http://www.tikirobot.net/wp/tag/lighttpd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tikirobot.net/wp</link>
	<description>Mai Tais and Blinky Lights, Ahoy!</description>
	<lastBuildDate>Wed, 01 Feb 2012 22:14:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to run lighttpd under upstart</title>
		<link>http://www.tikirobot.net/wp/2009/03/28/how-to-run-lighttpd-under-upstart/</link>
		<comments>http://www.tikirobot.net/wp/2009/03/28/how-to-run-lighttpd-under-upstart/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 04:23:51 +0000</pubDate>
		<dc:creator>rajbot</dc:creator>
				<category><![CDATA[code code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[support]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[upstart]]></category>

		<guid isPermaLink="false">http://www.tikirobot.net/wp/?p=2385</guid>
		<description><![CDATA[Upstart is Ubuntu&#8217;s init.d replacement. It greatly simplifies writing init.d scripts and has a great respawn feature similar to daemontool&#8217;s supervise or monit. And it comes with Ubuntu by default. For some reason, almost no one uses upstart. Even Ubuntu&#8217;s services use traditional /etc/init.d scripts instead of upstart scripts. I think this might be due [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://upstart.ubuntu.com/">Upstart</a> is Ubuntu&#8217;s init.d replacement. It greatly simplifies writing init.d scripts and has a great respawn feature similar to daemontool&#8217;s supervise or monit. And it comes with Ubuntu by default.</p>
<p>For some reason, almost no one uses upstart. Even Ubuntu&#8217;s services use traditional /etc/init.d scripts instead of upstart scripts. I think this might be due to upstart&#8217;s non-existent documentation. There is no man page for upstart, and multiple people I know who have read <a href="http://upstart.ubuntu.com/getting-started.html">the online docs</a> somehow missed the three important commands that control upstart jobs: <strong>/sbin/start</strong>, <strong>/sbin/stop</strong>, and <strong>/sbin/status</strong>!</p>
<p>Here is how it works: put an upstart script in /etc/event.d. Let&#8217;s call it /etc/event.d/foo. This script is now immediately available under upstart. Just type <tt><strong>sudo start foo</strong></tt>. That&#8217;s it.</p>
<p>I converted Ubuntu&#8217;s /etc/init.d/lighttpd script to a much shorter upstart script. The big advantage of this is upstart will restart lighttpd if it dies for some reason. This is what the upstart script looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#this is an upstart script that  starts lighttpd</span>
&nbsp;
start on runlevel <span style="color: #000000;">2</span>
start on runlevel <span style="color: #000000;">3</span>
start on runlevel <span style="color: #000000;">4</span>
start on runlevel <span style="color: #000000;">5</span>
&nbsp;
stop on runlevel <span style="color: #000000;">0</span>
stop on runlevel <span style="color: #000000;">1</span>
stop on runlevel <span style="color: #000000;">6</span>
&nbsp;
respawn
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-u</span> www-data lighttpd <span style="color: #660033;">-D</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>lighttpd<span style="color: #000000; font-weight: bold;">/</span>lighttpd-infobase.conf</pre></div></div>

<p>That&#8217;s it! Save this script as /etc/event.d/OL-lighttpd, and then type <tt><strong>sudo start OL-lighttpd</strong></tt>. You can kill off the lighttpd process and it will get restarted.</p>
<p>If you want to configure your lighttpd to write out a pid file, you can use pre-start and post-stop script to prepare and clean up the pid file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#this is an upstart script that  starts lighttpd</span>
&nbsp;
start on runlevel <span style="color: #000000;">2</span>
start on runlevel <span style="color: #000000;">3</span>
start on runlevel <span style="color: #000000;">4</span>
start on runlevel <span style="color: #000000;">5</span>
&nbsp;
stop on runlevel <span style="color: #000000;">0</span>
stop on runlevel <span style="color: #000000;">1</span>
stop on runlevel <span style="color: #000000;">6</span>
&nbsp;
&nbsp;
pre-start script
    <span style="color: #666666; font-style: italic;">#make sure there is a place to write the pid file (optional):</span>
    <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>lighttpd <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
    <span style="color: #c20cb9; font-weight: bold;">chown</span> www-data:www-data <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>lighttpd
    <span style="color: #c20cb9; font-weight: bold;">chmod</span> 0750 <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>lighttpd
end script
&nbsp;
respawn
<span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-u</span> www-data lighttpd <span style="color: #660033;">-D</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>lighttpd<span style="color: #000000; font-weight: bold;">/</span>lighttpd-infobase.conf
&nbsp;
post-stop script
    <span style="color: #666666; font-style: italic;">#remove pid file (optional)</span>
    <span style="color: #666666; font-style: italic;">#add server.pid-file = &quot;/var/run/lighttpd/lighttpd.pid&quot; to lighttpd.conf file to have it generate the pid file</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>lighttpd<span style="color: #000000; font-weight: bold;">/</span>lighttpd.pid
end script</pre></div></div>

<p>If you want to stop lighttpd, just type <tt><strong>sudo stop OL-lighttpd</strong></tt>. You can also type <tt><strong>sudo initctl list</strong></tt> for a list of all jobs under upstart.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tikirobot.net/wp/2009/03/28/how-to-run-lighttpd-under-upstart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

