[Catalyst] upstart script for Starman-based app?

Octavian Rasnita orasnita at gmail.com
Fri May 4 07:38:40 GMT 2012


From: "Dave Rolsky" <autarch at urth.org>
Subject: Re: [Catalyst] upstart script for Starman-based app?


> On Thu, 3 May 2012, Octavian Rasnita wrote:
> 
>> Does anyone have an upstart script that can be used for automaticly starting a Cat app using Starman?
>>
>> I use Perlbrew and local::lib and I start the app in my own account and not as root and I don't know how to make upstart start the app under my account.
>> Maybe it will be helpful to see an upstart script that works, and try to adapt it.
> 
> Here's an upstart script I use for vegguide.org. Note that I have root 
> access to my server, so you'll need to adjust a bit.
> 
>   description "VegGuide starman server"
> 
>   start on (local-filesystems and net-device-up IFACE!=lo)
>   stop on runlevel [016]
> 
>   respawn
>   limit as 524288000 524288000
> 
>   pre-start script
>       mkdir -p /var/run/vegguide
>       chown www-data:www-data /var/run/vegguide
> 
>       mkdir -p /var/log/vegguide
>       chown www-data:www-data /var/log/vegguide
>   end script
> 
>   exec /opt/perl5.14.2-no-threads/bin/starman --listen 127.0.0.1:8088 --workers 12 --preload-app --user www-data --group www-data /opt/perl5.14.2-no-threads/bin/vegguide.psgi 2>> /var/log/vegguide/error.log
> 
> This code base is in a git repo at git://git.urth.org/VegGuide.git
> 
> I also have a log monitor script which was watches this error log and 
> emails me when there are errors. I start that via upstart too, and it's 
> dependent on this job.
> 
> 
> -dave
> 


Hi Dave,

Thank you for your script. Finally I've made it to work, although there still is one thing I don't understand...

Here is my version (the paths are just for testing):

description "Startup script for the web site"

  start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]

env PERL5LIB=/home/teddy/perl5/lib1/lib/perl5/i686-linux:/home/teddy/perl5/lib1/lib/perl5
env PATH=/home/teddy/perl5/perlbrew/bin:/home/teddy/perl5/perlbrew/perls/perl-5.14.2/bin:/home/teddy/perl5/lib1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

export PERL5LIB
export PATH

expect fork

  respawn

exec /home/teddy/perl5/lib1/bin/starman --listen :5000 --workers 5 --max-requests 1000 --preload-app --pid /srv/log/site.pid --access-log /srv/log/access.log --error-log /srv/log/error.log --user teddy --group teddy --daemonize /srv/BRK/brk.psgi


I've also tried to exec a bash script that contains the same command above (without "exec") using:
exec /srv/BRK/start1.sh
But I don't know why it doesn't start the app this way.
If I exec the full command in the upstart script it works fine though.

I've seen that the app starts fine if I don't use the expect stanza, but in that case I can't close it using the stop command.
But I can start and stop it fine if I use either "expect fork" or "expect daemon".

Octavian




More information about the Catalyst mailing list