Before I go re-inventing the wheel, does anyone have a Ubuntu-flavoured init.d script for starting/stopping/restarting a plack-powered website?
-- Norm.
Ubuntu now uses Upstart, which seems very easy to write init scripts
for. See http://sysadvent.blogspot.com/2010/12/day-19-upstart.html
> -- Norm.
/ars
I personally like supervise. Create the supervise "run" scripts for
plackup and your logger:
$ mkdir -p myapp/services/myapp/log
$ cd myapp
$ cat > services/myapp/run
#!/bin/bash
exec softlimit -a 300000000 plackup myapp.psgi
$ cat > services/myapp/log/run
#!/bin/bash
exec multilog t '+*' 10000000s 10n ../logs/myapp/
(softlimit limits memory usage to 300M with setrlimit. It's optional,
but it's nice to not have your whole system go down because your web app
is leaky :)
Then start supervise, either by itself:
$ supervise services/myapp
Or, if you have a bunch of services in your services directory:
$ svscan services/myapp
Then you can check the status of your app easily:
$ svstat services/myapp
services/myapp/: up (pid 1234) 238473 seconds
And you can control it:
$ svc -t services/myapp # bounce myapp (kill with SIGTERM, supervise
restarts it)
$ svc -d services/myapp # bring down but don't restart
$ svc -s services/myapp # SIGSTOP
$ svc -c services/myapp # SIGCONT
I find this to be a lot easier than maintaining init scripts.
I am using this for a 10+-process app at work and am writing a plack app
for checking it all via the web. Take a look at metavise in my github
(when I push it, which will be later this week).
--Jon
--
print just => another => perl => hacker => if $,=$"
That does indeed look easy. Thanks very much!
(Which is not to say that the other solutions offered were useless, but I like to go with the grain of the OS :)
-- Norm.