From: "Tomas Doran" <bobtf...@bobtfish.net>
Subject: Re: [Catalyst] upstart script for Starman-based app?



On 3 May 2012, at 08:24, Octavian Rasnita wrote:

> Hi all,
> 
> 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.

Just write an upstart script that executes su - your user -c'xxxxx'. Or write a 
shell script that starts the app in the right way (when run as root) and 
execute that from upstart.

Except you do not want to run the app as the same user which installed it in 
production. You also don't want to run it as root (of course), but running it 
as your user gives the app permissions to re-write any of your files, including 
it's own source codeā€¦

Cheers
t0m



**
Yes, good tip for not running in production with the same user as the one that 
installed it.
But for the moment I just want to test the upstart script so I will run it with 
the same user.

No luck until now.

I have tried the following script (site.conf):

start on (mysql and runlevel [2345])
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

exec su - teddy -c'/srv/BRK/start_all_modules.sh'


But it didn't start the web server at all.
Then I copied the environment vars definitions in the script 
start_all_modules.sh which starts starman and this way it started the web 
server.
But the problem is that I can't stop it using upstart because it gives the 
error "unknown instance".

If I use the command status site, it gives the result "stop/waiting" even 
though the server is running.

root@ubuntu:/srv/log# start site; status site
site start/running, process 28528
site start/running, process 28528
root@ubuntu:/srv/log# status site
site stop/waiting

It appears that immediately after it starts, it passes to the stop/waiting mode.

I tried to add in the script:

instance $UPSTART_EVENTS
env UPSTART_EVENTS=

but no change.

Then I added:

expect daemon

After this change, it seems to start well and using status site doesn't show it 
as stopped anymore.
But if I want to stop it using stop site, it just sits and waits and I don't 
get the prompt back so after a long time I need to kill it and all the starman 
processes are running fine.

So I have tried expect fork instead.

But with this configuration it blocks when I use start site and it doesn't 
return the prompt, and of course, it doesn't start the server.

So.... I am surely missing something, and I don't know why I can't stop it 
using upstart.

Thanks.

Octavian


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to