Re: [Catalyst] upstart script for Starman-based app?

2012-05-16 Thread Dimitar Petrov
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 mose...@hank.org wrote:



 On Thu, May 3, 2012 at 2:24 AM, Octavian Rasnita orasn...@gmail.comwrote:

 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
 mose...@hank.org

 ___
 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/


___
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/


RE: [Catalyst] upstart script for Starman-based app? Errata to Starman-apache article

2012-05-16 Thread John Karr
There is some important errata to the advent Calendar article posted at: 
http://brainbuz.org/techinfo/2011/12/deploying-catalyst-with-starman-and-apache/

 

Unfortunately I have some frustration with upstart, I’m hoping to have better 
luck with the newest version in Ubuntu Precise. I will post a follow up article 
if I make progress with the new version of upstart. You may want to consider 
using the rc.local method if upstart is too problematic. 

 

From: Dimitar Petrov [mailto:mita...@gmail.com] 
Sent: Wednesday, May 16, 2012 6:00 AM
To: The elegant MVC web framework
Subject: Re: [Catalyst] upstart script for Starman-based app?

 

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 mose...@hank.org wrote:

 

On Thu, May 3, 2012 at 2:24 AM, Octavian Rasnita orasn...@gmail.com 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
mose...@hank.org

___
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/

 

___
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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-16 Thread Octavian Rasnita
From: Bill Moseley 
  Subject: Re: [Catalyst] upstart script for Starman-based app?





  On Thu, May 3, 2012 at 2:24 AM, Octavian Rasnita orasn...@gmail.com 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


___
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/


RE: [Catalyst] upstart script for Starman-based app?

2012-05-09 Thread Jack Downes
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:tly...@ivenue.com] 
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 orasn...@gmail.com
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@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/

___
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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-09 Thread Octavian Rasnita
From: Jack Downes jdow...@krmc.org
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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-07 Thread Dave Rolsky

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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-06 Thread Octavian Rasnita

From: Todd Lyons tly...@ivenue.com
Subject: Re: [Catalyst] upstart script for Starman-based app?



On Thu, May 3, 2012 at 12:24 AM, Octavian Rasnita orasn...@gmail.com
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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-06 Thread Dave Rolsky

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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-06 Thread Octavian Rasnita
From: Dave Rolsky auta...@urth.org
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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-04 Thread Octavian Rasnita
From: Dave Rolsky auta...@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


___
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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-04 Thread Octavian Rasnita

From: Dave Rolsky auta...@urth.org
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@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/


[Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Octavian Rasnita
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@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/


RE: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Morad IGMIR
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:orasn...@gmail.com] 
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@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/


___
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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Octavian Rasnita
From: Morad IGMIR mig...@alliancemca.com
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@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/


RE: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Morad IGMIR
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 21
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:orasn...@gmail.com] 
Envoyé : jeudi 3 mai 2012 11:47
À : The elegant MVC web framework
Objet : Re: [Catalyst] upstart script for Starman-based app?

From: Morad IGMIR mig...@alliancemca.com
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@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/


___
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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Tomas Doran

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'x'. 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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Octavian Rasnita
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'x'. 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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Octavian Rasnita
From: Morad IGMIR mig...@alliancemca.com
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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Eden Cardim
 Octavian == Octavian Rasnita orasn...@gmail.com 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.comhttp://www.shadowcat.co.uk/servers/

___
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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Christiaan Kras

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@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/


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@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/


Re: [Catalyst] upstart script for Starman-based app?

2012-05-03 Thread Dave Rolsky

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@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/