How to setup a runit service for grails
Today I had a task to setup continuous integration for grails on EC2 server. I asked Google for a solution and it returns no results, so I want to share my experience., maybe it will be helpful for other system administrators.
Below is a little script that do all automatically, you will need just to start the service with:
sv start grails
You can also add a hourly cron job to update grails application from git or subversion.
setup_grails_runit.sh
#!/bin/sh
#
apt-get install runit
sv_dir=/etc/sv/grails
mkdir -p $sv_dir/log
cat - > $sv_dir/run <<EOF
#!/bin/sh
export JAVA_HOME='/opt/jdk1.6.0_10'
export PATH=${JAVA_HOME}/bin:$PATH
export JIBX_HOME='/opt/jibx'
export PATH=${JIBX_HOME}/bin:$PATH
cd /opt/apps/my_project
exec grails -Dserver.port=80 run-app
EOF
cat - > $sv_dir/log/run <<EOF
#!/bin/sh
set -e
# use /mnt, because on EC2 a bigger disk is mounted to /mnt
LOG=/mnt/log/grails
test -d "$LOG" || mkdir -p -m2750 "$LOG" && chown nobody:adm "$LOG"
exec chpst -unobody svlogd -tt "$LOG"
EOF
chmod 755 $sv_dir/run $sv_dir/log/run
# add service
update-service --add $sv_dir
0 Comments:
Post a Comment
<< Home