Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
153 lines (113 sloc) 5.01 KB
starmachine_init.d - shared LSB init.d script for running PSGI apps with
A management suite for production deployments of one or more PSGI web
apps under *nix. Runs each app with Starman, and can use independent
sets of libraries (e.g. "extlib/" dirs) for each app. Right now, the
"suite" is just a flexible init.d script. But this might grow into a
suite. Or it may not.
The init script itself depends only on core Perl 5.6, although of course
Starman and Server::Starter, plus your application's dependencies, must
of course be available either in the main system or in your app's extlib
for your app to run (see extlib conf var below).
Most basic setup - single app
git clone git://
cd starmachine;
ln -s /path/to/myapp .;
sudo ln -s $PWD/bin/starmachine_init.d /etc/init.d/myapp;
sudo /etc/init.d/myapp start
And now /etc/init.d/myapp is a well-behaved init script that starts your
app under Starman using /path/to/myapp/script/myapp.psgi with 10
workers, on port 8080, putting the logs in the starmachine dir.
Starmachine has very sensible defaults, but almost everything it does is
configurable via its configuration file. It searches for that
configuration file in 3 places, and uses the first one it finds:
The file name stored in the C<STARMACHINE_CONF> environment
variable, or if that is a directory, the file
C<$STARMACHINE_CONF/starmachine.conf> in that directory.
Relative to the (real) path from which this script is invoked. This
means you can just run Starmachine out of a git checkout if you
Configuration format
An example configuration file for three apps
("ambikon_integrationserver", "sgn", and "mimosa"), looks like this:
root_dir = /path/to/starmachine/root
env[CATALYST_CONFIG] = /etc/starmachine
# conf for the ambikon front-end proxy
ambikon_integrationserver[port] = 80
ambikon_integrationserver[user] = www-data
# conf for the SGN legacy app
sgn[port] = 8201
sgn[user] = sgn_web
# conf for the Mimosa aligner app
mimosa[port] = 8202
mimosa[user] = mimosa
mimosa[access_log] = /var/log/mimosa.access.log
mimosa[error_log] = /var/log/mimosa.error.log
Main configuration variables
The directory under which each application directory is assumed to
reside, unless otherwise specified with "myapp[app_dir]". Defaults
to the config file's directory.
env Environment variables to set for all apps.
# set all Catalyst apps to look for their conf files in
# /etc/starmachine
env[CATALYST_CONFIG] = /etc/starmachine
Application configuration variables
Port the app will listen on. Default 8080.
User that the app will run under. Defaults to the user that runs the
init.d script.
Group that the app will run under. Defaults to the primary group of
the user that runs the init.d script.
Variables to set in the app's environment.
myapp[env][CATALYST_CONFIG] = /path/to/myapp.conf
myapp[env][FOOBAR] = baz_1
Number of worker processes to use. Default 10.
todo. Default 20.
Default 1. If 1, preload the application in the parent process
before forking workers.
Default empty. String interpolated directly into the invocation of
"start_server" (see start_server).
Default empty. String interpolated directly into the invocation of
"starman" (see starman).
Access log file. Default "(starmachine_root)/(app_name).access.log".
Error log file. Default "(starmachine_root)/(app_name).error.log"
Application main directory. Default
Path (relative to app_dir, or absolute) of PSGI file to use for
starting the app.
PID file in which to store the PID of the Server::Starter parent
process. Default "(starmachine_root)/(app_name).pid".
Server::Starter status file. Default
Path to bundled dependencies (extlibs) of the app, either relative
to the app_dir, or absolute. Default: "extlib".
Copyright 2011 Robert Buels
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Robert Buels <>