Fixed the template and the tests

This commit is contained in:
Emile Cantin 2012-04-25 10:24:29 -04:00
parent ab1594bc72
commit 41477e8453
3 changed files with 24 additions and 11 deletions

View File

@ -19,7 +19,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Runs <%= app %>"
NAME=<%= app %>
PIDDIR=/var/run/$NAME
LOGDIR=/var/log/$NAME
LOGDIR=<%= log_root %>
SCRIPTNAME=/etc/init.d/$NAME
USERNAME=<%= user %>
@ -49,7 +49,7 @@ do_start()
# START CONCURRENT: <%= num %>
# Start: <%= app %>.<%= process.name %>.<%= num %>
# Create $PIDDIR/<%= process.name %>.<%= num %>.pid
exec su - USERNAME -c 'cd <%= engine.directory %>; export PORT=<%= engine.port_for(process, num, self.port) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= process.name %>.<%= num %>.pid
su - $USERNAME -c 'cd <%= engine.directory %>; export PORT=<%= engine.port_for(process, num, self.port) %>;<% engine.environment.each_pair do |var,env| %> export <%= var.upcase %>=<%= env %>; <% end %> <%= process.command %> >> $LOGDIR/<%=process.name%>-<%=num%>.log 2>&1 & echo $!' > $PIDDIR/<%= process.name %>.<%= num %>.pid
<% end %>
<% end %>
@ -66,7 +66,8 @@ do_stop()
<% 1.upto(concurrency[process.name]) do |num| %>
# STOP CONCURRENT: <%= num %>
# Stop: <%= app %>.<%= process.name %>.<%= num %>
kill `echo $PIDDIR/<%= process.name %>.<%= num %>.pid`
kill `cat $PIDDIR/<%= process.name %>.<%= num %>.pid`
rm $PIDDIR/<%= process.name %>.<%= num %>.pid
<% end %>
<% end %>
rmdir $PIDDIR

View File

@ -19,7 +19,9 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Runs app"
NAME=app
PIDDIR=/var/run/$NAME
LOGDIR=/var/log/app
SCRIPTNAME=/etc/init.d/$NAME
USERNAME=app
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
@ -38,6 +40,8 @@ SCRIPTNAME=/etc/init.d/$NAME
do_start()
{
mkdir -p $PIDDIR
mkdir -p $LOGDIR
chown $USERNAME: $LOGDIR
# START APPLICATION: app
# START PROCESS: alpha
@ -45,7 +49,7 @@ do_start()
# START CONCURRENT: 1
# Start: app.alpha.1
# Create $PIDDIR/alpha.1.pid
exec su - app -c 'cd /tmp/app; export PORT=5000; ./alpha >> /var/log/app/alpha-1.log 2>&1 & echo $!' > $PIDDIR/alpha.1.pid
su - $USERNAME -c 'cd /tmp/app; export PORT=5000; ./alpha >> $LOGDIR/alpha-1.log 2>&1 & echo $!' > $PIDDIR/alpha.1.pid
# START PROCESS: bravo
@ -53,7 +57,7 @@ do_start()
# START CONCURRENT: 1
# Start: app.bravo.1
# Create $PIDDIR/bravo.1.pid
exec su - app -c 'cd /tmp/app; export PORT=5100; ./bravo >> /var/log/app/bravo-1.log 2>&1 & echo $!' > $PIDDIR/bravo.1.pid
su - $USERNAME -c 'cd /tmp/app; export PORT=5100; ./bravo >> $LOGDIR/bravo-1.log 2>&1 & echo $!' > $PIDDIR/bravo.1.pid
@ -70,14 +74,16 @@ do_stop()
# STOP CONCURRENT: 1
# Stop: app.alpha.1
kill `echo $PIDDIR/alpha.1.pid`
kill `cat $PIDDIR/alpha.1.pid`
rm $PIDDIR/alpha.1.pid
# STOP PROCESS: bravo
# STOP CONCURRENT: 1
# Stop: app.bravo.1
kill `echo $PIDDIR/bravo.1.pid`
kill `cat $PIDDIR/bravo.1.pid`
rm $PIDDIR/bravo.1.pid
rmdir $PIDDIR

View File

@ -19,7 +19,9 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Runs app"
NAME=app
PIDDIR=/var/run/$NAME
LOGDIR=/var/log/app
SCRIPTNAME=/etc/init.d/$NAME
USERNAME=app
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
@ -38,6 +40,8 @@ SCRIPTNAME=/etc/init.d/$NAME
do_start()
{
mkdir -p $PIDDIR
mkdir -p $LOGDIR
chown $USERNAME: $LOGDIR
# START APPLICATION: app
# START PROCESS: alpha
@ -45,13 +49,13 @@ do_start()
# START CONCURRENT: 1
# Start: app.alpha.1
# Create $PIDDIR/alpha.1.pid
exec su - app -c 'cd /tmp/app; export PORT=5000; ./alpha >> /var/log/app/alpha-1.log 2>&1 & echo $!' > $PIDDIR/alpha.1.pid
su - $USERNAME -c 'cd /tmp/app; export PORT=5000; ./alpha >> $LOGDIR/alpha-1.log 2>&1 & echo $!' > $PIDDIR/alpha.1.pid
# START CONCURRENT: 2
# Start: app.alpha.2
# Create $PIDDIR/alpha.2.pid
exec su - app -c 'cd /tmp/app; export PORT=5001; ./alpha >> /var/log/app/alpha-2.log 2>&1 & echo $!' > $PIDDIR/alpha.2.pid
su - $USERNAME -c 'cd /tmp/app; export PORT=5001; ./alpha >> $LOGDIR/alpha-2.log 2>&1 & echo $!' > $PIDDIR/alpha.2.pid
# START PROCESS: bravo
@ -69,12 +73,14 @@ do_stop()
# STOP CONCURRENT: 1
# Stop: app.alpha.1
kill `echo $PIDDIR/alpha.1.pid`
kill `cat $PIDDIR/alpha.1.pid`
rm $PIDDIR/alpha.1.pid
# STOP CONCURRENT: 2
# Stop: app.alpha.2
kill `echo $PIDDIR/alpha.2.pid`
kill `cat $PIDDIR/alpha.2.pid`
rm $PIDDIR/alpha.2.pid
# STOP PROCESS: bravo