Yesterday, I was working on Running PyBlosxom through SCGI, but
during that time, I was running the SCGI server by hand in a console window.
Once it was working I needed to arrange a way to run this in a more permanent fashion.
Daemontools seems like an easy way to set this up, I already had it
running on my server.
Daemontools runs a process called
that looks for directories in
/var/service (the default when installed through the FreeBSD port)
that contain an executable named
also finds a
log/run executable in that directory, it starts that too and ties the two together
with a pipe. Daemontools includes a
program that reads from the pipe (stdin), and writes out and rotates log file for you automatically.
To get PyBlosxom/SCGI running under this, started by making a temporary directory, and copying in the
three files needed to run PyBlosxom through SCGI
cp ~/config.py .
cp ~/wsgi_app.py .
cp ~/scgi_server.py .
(The first two files come from the PyBlosxom distribtution (the first one is customized). The third
file is the one I came up with yesterday)
Next, I came up with a
run script to execute the SCGI server under the
stderr tied to
stdout. Daemontools has a
program that makes this pretty easy
exec setuidgid www ./scgi_server.py
Next, made a
log subdirectory, a
to hold the actual log files (owned by
chown www:www log/main
And in the
log directory put another tiny
exec setuidgid www multilog t ./main
Finally, made both
run scripts executable, and moved the whole thing
chmod +x run
chmod +x log/run
mv pyblosxom /var/service
svscan sees the new directories within a few seconds, starts up both
run scripts automatically, and you're in business. See the current contents
of the log with:
Stop and restart the server with the Daemontools
svc -d pyblosxom ; svc -u pyblosxom