Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

upstart script for Starman-based app?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


orasnita at gmail

May 3, 2012, 12:24 AM

Post #1 of 24 (871 views)
Permalink
upstart script for Starman-based app?

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.

Thanks.

--Octavian


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


migmir at alliancemca

May 3, 2012, 12:56 AM

Post #2 of 24 (863 views)
Permalink
RE: upstart script for Starman-based app? [In reply to]

I'm currently using CatalystX::Script::Server::Starman to do just this, it
works fine so far, and you don't need to adapt your script, just use
myapp_server.pl

https://metacpan.org/module/CatalystX::Script::Server::Starman

-----Message d'origine-----
De : Octavian Rasnita [mailto:orasnita [at] gmail]
Envoyé : jeudi 3 mai 2012 09:24
À : The elegant MVC web framework
Objet : [Catalyst] upstart script for Starman-based app?

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.

Thanks.

--Octavian


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


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


orasnita at gmail

May 3, 2012, 2:47 AM

Post #3 of 24 (861 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Morad IGMIR" <migmir [at] alliancemca>
Subject: RE: [Catalyst] upstart script for Starman-based app?


I'm currently using CatalystX::Script::Server::Starman to do just this, it
works fine so far, and you don't need to adapt your script, just use
myapp_server.pl

https://metacpan.org/module/CatalystX::Script::Server::Starman




Thanks. I know about it, but it doesn't solve what I want... to start the web server automaticly when the computer starts after MySQL was started.

Octavian



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


migmir at alliancemca

May 3, 2012, 3:06 AM

Post #4 of 24 (865 views)
Permalink
RE: upstart script for Starman-based app? [In reply to]

So you're looking for an /etc/init.d/ init script ?

If so, here's a generic version of mine I use, again, in conjunction with
Cx:S:S:Starman

#! /bin/bash
DAEMON_NAME="myapp"
DAEMON_SCRIPT="${DAEMON_NAME}_server"
DAEMON=$(which $DAEMON_SCRIPT)
DAEMON_USER="user"
DAEMON_RUN_DIR="/var/run/starman"
DAEMON_RUN_FILE="${DAEMON_RUN_DIR}/${DAEMON_NAME}.run"
PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

#starman
DAEMON_HOST="0.0.0.0"
DAEMON_PORT=21000
DAEMON_WORKERS=10
DAEMON_CMD="$DAEMON -h $DAEMON_HOST -p $DAEMON_PORT --pidfile
$DAEMON_RUN_FILE --background --workers $DAEMON_WORKERS 2>/dev/null"
#end

. /lib/lsb/init-functions

if [ -n "$DAEMON" -a -x "$DAEMON" ]
then
echo ""
else
log_daemon_msg "${DAEMON_SCRIPT} not found in path ${DAEMON}"
exit
fi

d_start () {
if [ ! -f $DAEMON_RUN_FILE ]
then
if [ ! -d $DAEMON_RUN_DIR ]
then
mkdir $DAEMON_RUN_DIR
chown $DAEMON_USER:root $DAEMON_RUN_DIR
chmod 774 $DAEMON_RUN_DIR
fi
log_daemon_msg "Starting $DAEMON_NAME"
su -l $DAEMON_USER -c "perl $DAEMON_CMD"
log_end_msg $?
else
log_daemon_msg "Error when starting $DAEMON_NAME :
$DAEMON_RUN_FILE found"
fi
}

d_stop () {
if [ -f $DAEMON_RUN_FILE ]
then
log_daemon_msg "Stopping system $DAEMON_NAME Daemon"
RUN=$(head -n1 $DAEMON_RUN_FILE)
if [ "x" != "x$RUN" ]
then
kill $RUN
fi
rm -rf $DAEMON_RUN_FILE
log_end_msg $?
else
log_daemon_msg "Error when stopping $DAEMON_NAME :
$DAEMON_RUN_FILE not found"
fi
}

case "$1" in

start|stop)
d_${1}
;;

restart)
d_stop
d_start
;;

status)
if [ -f $DAEMON_RUN_FILE ]
then
RUN=$(head -n1 $DAEMON_RUN_FILE)
ps -p $RUN 1>/dev/null 2>&1
if [ $? == 0 ]
then
echo "$DAEMON_NAME is running with PID
${RUN}."
else
echo "$DAEMON_NAME is not running but
$DAEMON_RUN_FILE subsist."
fi
else
echo "$DAEMON_NAME is not running"
fi
;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME
{start|stop|restart|status}"
exit 1
;;
esac
exit 0

-----Message d'origine-----
De : Octavian Rasnita [mailto:orasnita [at] gmail]
Envoyé : jeudi 3 mai 2012 11:47
À : The elegant MVC web framework
Objet : Re: [Catalyst] upstart script for Starman-based app?

From: "Morad IGMIR" <migmir [at] alliancemca>
Subject: RE: [Catalyst] upstart script for Starman-based app?


I'm currently using CatalystX::Script::Server::Starman to do just this, it
works fine so far, and you don't need to adapt your script, just use
myapp_server.pl

https://metacpan.org/module/CatalystX::Script::Server::Starman




Thanks. I know about it, but it doesn't solve what I want... to start the
web server automaticly when the computer starts after MySQL was started.

Octavian



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


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


bobtfish at bobtfish

May 3, 2012, 3:09 AM

Post #5 of 24 (866 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

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


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


orasnita at gmail

May 3, 2012, 5:01 AM

Post #6 of 24 (865 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Tomas Doran" <bobtfish [at] bobtfish>
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 [at] ubunt:/srv/log# start site; status site
site start/running, process 28528
site start/running, process 28528
root [at] ubunt:/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 [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


octavian.rasnita at ssifbroker

May 3, 2012, 5:27 AM

Post #7 of 24 (858 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Morad IGMIR" <migmir [at] alliancemca>
Subject: RE: [Catalyst] upstart script for Starman-based app?


So you're looking for an /etc/init.d/ init script ?



Thank you for your script. I hope I will be able to use an upstart script, because upstart requires much less code and it is more powerful than the old SysV init style scripts, but if I won't find a solution for the problem I found in my script, I'll probably go back and create a script based on yours.

Octavian


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


edencardim at gmail

May 3, 2012, 7:14 AM

Post #8 of 24 (860 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

>>>>> "Octavian" == Octavian Rasnita <orasnita [at] gmail> writes:

Octavian> Thanks. I know about it, but it doesn't solve what I want... to
Octavian> start the web server automaticly when the computer starts after
Octavian> MySQL was started.

Note that if you'd using Catalyst::Model::DBIC::Schema, you don't need to wait
for MySQL to come up, as it does lazy connecting. If someone issues a request
during the mysql startup time, they'll get a 500 error, which you can handle
via an error document and is much better than a plain 404.

--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://edencardim.com http://www.shadowcat.co.uk/servers/

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


c.kras at pcc-online

May 3, 2012, 11:55 AM

Post #9 of 24 (855 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

Op 3-5-2012 9:24, Octavian Rasnita schreef:
> 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.
>
> Thanks.
>
> --Octavian
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/

I've started using Daemon::Control
(https://metacpan.org/module/Daemon::Control) for my init.d scripts and
this module makes it very bearable. I haven't used it for Starman yet,
but for Plackup it worked just fine.

--
Christiaan Kras
http://blog.htbaa.com

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


autarch at urth

May 3, 2012, 3:45 PM

Post #10 of 24 (860 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

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

/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/

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


orasnita at gmail

May 4, 2012, 12:38 AM

Post #11 of 24 (874 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Dave Rolsky" <autarch [at] urth>
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


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


octavian.rasnita at ssifbroker

May 4, 2012, 12:49 AM

Post #12 of 24 (855 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Eden Cardim" <edencardim [at] gmail>
Subject: Re: [Catalyst] upstart script for Starman-based app?


>>>>>> "Octavian" == Octavian Rasnita <orasnita [at] gmail> writes:
>
> Octavian> Thanks. I know about it, but it doesn't solve what I want... to
> Octavian> start the web server automaticly when the computer starts after
> Octavian> MySQL was started.
>
> Note that if you'd using Catalyst::Model::DBIC::Schema, you don't need to wait
> for MySQL to come up, as it does lazy connecting. If someone issues a request
> during the mysql startup time, they'll get a 500 error, which you can handle
> via an error document and is much better than a plain 404.
>
> --
> Eden Cardim Need help with your Catalyst or DBIx::Class project?



Yep, I am using it, but I also use Catalyst::Plugin::I18N::DBI which tries to connect at startup to get the translation strings, and the app can't start because it gives a fatal error.

Octavian




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


autarch at urth

May 4, 2012, 8:43 AM

Post #13 of 24 (848 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

On Fri, 4 May 2012, Octavian Rasnita wrote:

> expect fork

I'm not sure why you need this. There's no fork happening with your
config, AFAICT.

> 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.

No idea.

To be honest, I kind of hate upstart. It's really freaking inscrutable and
the docs suck. I've gotten some info out of it by putting it into debug
mode and watching /var/log/daemon.log

I really wish Ubuntu would just kill upstart and switch to systemd.

> 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".

Weird. I don't need this at all for my system.


-dave

/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/

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


orasnita at gmail

May 4, 2012, 9:32 AM

Post #14 of 24 (836 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

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


> On Fri, 4 May 2012, Octavian Rasnita wrote:
>
>> expect fork
>
> I'm not sure why you need this. There's no fork happening with your
> config, AFAICT.



But isn't Starman doing a fork?

> To be honest, I kind of hate upstart. It's really freaking inscrutable and
> the docs suck. I've gotten some info out of it by putting it into debug
> mode and watching /var/log/daemon.log
>
> I really wish Ubuntu would just kill upstart and switch to systemd.

I have never used nor seen a systemd script although I heard about it.
I was able to compare just the huge and complicated systemv init scripts and
upstart, and upstart is better (if it works:)

Isn't OK to install systemd using apt-get?

I've found that there is a systemd package available for Ubuntu:
p live-config-systemd - Debian
Live - System Configuration Scripts (systemd backend)

Octavian


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


tlyons at ivenue

May 6, 2012, 8:59 AM

Post #15 of 24 (833 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

On Thu, May 3, 2012 at 12:24 AM, Octavian Rasnita <orasnita [at] gmail> 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.

What follows is for starting a python app as an unprivileged user with
upstart, I don't think it would be too difficult to adjust it for your
starman based app:

http://stackoverflow.com/questions/10250682/how-to-write-an-ubuntu-upstart-job-for-celery-django-celery-in-a-virtualenv

Follow the link in the first answer for the authoritative confirming
response from the upstart guys:
http://superuser.com/questions/213416/running-upstart-jobs-as-unprivileged-users/234541#234541

...Todd
--
Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live. -- Martin Golding

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


orasnita at gmail

May 6, 2012, 10:27 AM

Post #16 of 24 (832 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Todd Lyons" <tlyons [at] ivenue>
Subject: Re: [Catalyst] upstart script for Starman-based app?


> On Thu, May 3, 2012 at 12:24 AM, Octavian Rasnita <orasnita [at] gmail>
> 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.
>
> What follows is for starting a python app as an unprivileged user with
> upstart, I don't think it would be too difficult to adjust it for your
> starman based app:
>
> http://stackoverflow.com/questions/10250682/how-to-write-an-ubuntu-upstart-job-for-celery-django-celery-in-a-virtualenv
>
> Follow the link in the first answer for the authoritative confirming
> response from the upstart guys:
> http://superuser.com/questions/213416/running-upstart-jobs-as-unprivileged-users/234541#234541
>
> ...Todd
> --



Thanks. Even though I've succeeded to make it work in a different way, I
will also try these
ways.

Octavian



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


autarch at urth

May 6, 2012, 10:17 PM

Post #17 of 24 (834 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

On Fri, 4 May 2012, Octavian Rasnita wrote:

>>> expect fork
>>
>> I'm not sure why you need this. There's no fork happening with your config,
>> AFAICT.
>
> But isn't Starman doing a fork?

Yes, but the "expect fork" is telling upstart to expect the process to
fork once and create a single child, letting the parene exit. Upstart will
track the pid of the child and kill that when you stop the process.

With Starman, the parent stays active, and it's what should be killed when
you want to stop the process.

>> To be honest, I kind of hate upstart. It's really freaking inscrutable and
>> the docs suck. I've gotten some info out of it by putting it into debug
>> mode and watching /var/log/daemon.log
>>
>> I really wish Ubuntu would just kill upstart and switch to systemd.
>
> I have never used nor seen a systemd script although I heard about it.
> I was able to compare just the huge and complicated systemv init scripts and
> upstart, and upstart is better (if it works:)
>
> Isn't OK to install systemd using apt-get?
>
> I've found that there is a systemd package available for Ubuntu:
> p live-config-systemd - Debian Live -
> System Configuration Scripts (systemd backend)

That won't magically make all the other packages use systemd instead of
upstart, and I don't think trying to run two init daemons is a great idea
;)


-dave

/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/

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


orasnita at gmail

May 6, 2012, 10:36 PM

Post #18 of 24 (832 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

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


> On Fri, 4 May 2012, Octavian Rasnita wrote:
>
>>>> expect fork
>>>
>>> I'm not sure why you need this. There's no fork happening with your config,
>>> AFAICT.
>>
>> But isn't Starman doing a fork?
>
> Yes, but the "expect fork" is telling upstart to expect the process to
> fork once and create a single child, letting the parene exit. Upstart will
> track the pid of the child and kill that when you stop the process.
>
> With Starman, the parent stays active, and it's what should be killed when
> you want to stop the process.
>


I see that this is not happening, at least if starman receives the --user and --group parameters.

I have use --user teddy --group teddy in the upstart config, and even though I execute "start prg" and "stop prg" from the root account, all the starman processes are owned by teddy account. And there are 11 processes, even though I asked starman to run 10 children, so the master process is also owned by teddy account.


>>> To be honest, I kind of hate upstart. It's really freaking inscrutable and
>>> the docs suck. I've gotten some info out of it by putting it into debug
>>> mode and watching /var/log/daemon.log
>>>
>>> I really wish Ubuntu would just kill upstart and switch to systemd.
>>
>> I have never used nor seen a systemd script although I heard about it.
>> I was able to compare just the huge and complicated systemv init scripts and
>> upstart, and upstart is better (if it works:)
>>
>> Isn't OK to install systemd using apt-get?
>>
>> I've found that there is a systemd package available for Ubuntu:
>> p live-config-systemd - Debian Live -
>> System Configuration Scripts (systemd backend)
>
> That won't magically make all the other packages use systemd instead of
> upstart, and I don't think trying to run two init daemons is a great idea
> ;)
>
>
> -dave


I've seen that not all the processes started automaticly use upstart under Ubuntu.
For example, I can manage apache2 process using
service apache2 status
but not
status apache

because apache2 uses a SystemV script.

I read somewhere that upstart can work somehow with upstart scripts, but that the old SysV init scripts are also executed... but I don't know if it can also work in the same way with SysD scripts...

Octavian


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


autarch at urth

May 7, 2012, 9:22 AM

Post #19 of 24 (830 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

On Mon, 7 May 2012, Octavian Rasnita wrote:

>> With Starman, the parent stays active, and it's what should be killed when
>> you want to stop the process.
>
> I see that this is not happening, at least if starman receives the --user and --group parameters.
>
> I have use --user teddy --group teddy in the upstart config, and even though I execute "start prg" and "stop prg" from the root account, all the starman processes are owned by teddy account. And there are 11 processes, even though I asked starman to run 10 children, so the master process is also owned by teddy account.

Hmm, weird. Maybe I'm wrong, in which case I have no idea how my config
file works without "expect fork".

> I've seen that not all the processes started automaticly use upstart under Ubuntu.
> For example, I can manage apache2 process using
> service apache2 status
> but not
> status apache
>
> because apache2 uses a SystemV script.
>
> I read somewhere that upstart can work somehow with upstart scripts, but
> that the old SysV init scripts are also executed... but I don't know if
> it can also work in the same way with SysD scripts...

Ubuntu is in the process of moving things from SysV to Upstart. In 10.04,
very few daemons use upstart. I expect that's changed in 12.04.

Regardless, using systemd doesn't seem feasible.


-dave

/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/

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


jdownes at krmc

May 9, 2012, 8:31 AM

Post #20 of 24 (820 views)
Permalink
RE: upstart script for Starman-based app? [In reply to]

I do something similar with FreeBSD. My install consists of a local
install of perl, cat, dbic, etc to get my app running. I use nginx from
system configured as a proxy. Now, I see a lot of people using Starman
with nginx and you are asking for Starman, so that's doable... Anyway I
use nginx to proxy to the fastcgi process... I'm pretty sure this isn't
starman, but then, I don't know for sure.

My point in this is that I have not written rc scripts for my catalyst
app, and probably won't. There exists another way which, for me as a
standard user on this system is pretty much perfect

I use @reboot in the crontab. Perhaps this will work for you as well?
It's quite simple... perhaps overly so.

Jack Downes
HIT / KRMC
751 4118

-- Discipline is remembering what you want. --
-----Original Message-----
From: Todd Lyons [mailto:tlyons [at] ivenue]
Sent: Sunday, May 06, 2012 9:59 AM
To: The elegant MVC web framework
Subject: Re: [Catalyst] upstart script for Starman-based app?

On Thu, May 3, 2012 at 12:24 AM, Octavian Rasnita <orasnita [at] gmail>
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.

What follows is for starting a python app as an unprivileged user with
upstart, I don't think it would be too difficult to adjust it for your
starman based app:

http://stackoverflow.com/questions/10250682/how-to-write-an-ubuntu-upsta
rt-job-for-celery-django-celery-in-a-virtualenv

Follow the link in the first answer for the authoritative confirming
response from the upstart guys:
http://superuser.com/questions/213416/running-upstart-jobs-as-unprivileg
ed-users/234541#234541

...Todd
--
Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live. -- Martin Golding

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

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


orasnita at gmail

May 9, 2012, 10:55 PM

Post #21 of 24 (811 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: "Jack Downes" <jdownes [at] krmc>
Subject: RE: [Catalyst] upstart script for Starman-based app?


I do something similar with FreeBSD. My install consists of a local
install of perl, cat, dbic, etc to get my app running. I use nginx from
system configured as a proxy. Now, I see a lot of people using Starman
with nginx and you are asking for Starman, so that's doable... Anyway I
use nginx to proxy to the fastcgi process... I'm pretty sure this isn't
starman, but then, I don't know for sure.

My point in this is that I have not written rc scripts for my catalyst
app, and probably won't. There exists another way which, for me as a
standard user on this system is pretty much perfect

I use @reboot in the crontab. Perhaps this will work for you as well?
It's quite simple... perhaps overly so.

Jack Downes



Not exactly. I would also like to be able to use a simple command to stop/restart/start the app manually if I need it, like
start app
or
service app start

because I know how to kill -QUIT `cat file.pid`, but this would appear pretty complicated if I must tell it to somebody else by phone to use it if necessary.

Octavian


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


moseley at hank

May 15, 2012, 6:20 AM

Post #22 of 24 (776 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

On Thu, May 3, 2012 at 2:24 AM, Octavian Rasnita <orasnita [at] gmail> 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.
>

I'm curious: why you use both Perlbrew and local::lib vs. installing all
modules in the Perlbrew Perl lib?

Thanks,


--
Bill Moseley
moseley [at] hank


mitakaa at gmail

May 16, 2012, 3:00 AM

Post #23 of 24 (764 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

There was an article about Starman and Apache into the last year Advent
Calendar. Here is the link:
http://www.catalystframework.org/calendar/2011/16

Cheers

On Tue, May 15, 2012 at 3:20 PM, Bill Moseley <moseley [at] hank> wrote:

>
>
> On Thu, May 3, 2012 at 2:24 AM, Octavian Rasnita <orasnita [at] gmail>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.
>>
>
> I'm curious: why you use both Perlbrew and local::lib vs. installing all
> modules in the Perlbrew Perl lib?
>
> Thanks,
>
>
> --
> Bill Moseley
> moseley [at] hank
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>


orasnita at gmail

May 16, 2012, 9:13 AM

Post #24 of 24 (772 views)
Permalink
Re: upstart script for Starman-based app? [In reply to]

From: Bill Moseley
Subject: Re: [Catalyst] upstart script for Starman-based app?





On Thu, May 3, 2012 at 2:24 AM, Octavian Rasnita <orasnita [at] gmail> 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.



I'm curious: why you use both Perlbrew and local::lib vs. installing all modules in the Perlbrew Perl lib?


Thanks,


Hi Bill,

No special super technical reason. I use Perlbrew because I want to leave the system Perl alone, and I thought that I will use a single Perlbrew and a different local::lib dir for the 2 different apps I made. But finally I installed a separate Perlbrew for each of them.

Octavian

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.