This is the best I’ve come across. Granted, I’ve not spent a ton of time having to look, but when I have it’s not been this clear.
You can just run pretty much anything you want in that last “exec….” part. Just route the output to /dev/null 2>&1 and you’re set.
Then run it with:
initctl start myservice
initctl stop myservice
create a file at /etc/init/myservice.conf with the following contents:
description “Tomcat 7 service”
#So that you remember what the services does
start on runlevel [2345]
# When the service should start. 2, 3, 4 and 5 are
# runlevels that are various flavours of system startup.
stop on runlevel [06]
# 0 is for system halt and 6 is for system reboot
respawn
# If the service is stopped otherwise than with a proper ‘stop’
# message (system halt or reboot), the service will restart automatically
respawn limit 3 10
# In case the service cannot boot properly (e.g. misconfiguration),
# this prevents the service to go crazy an reboot endlessly.
# 3 10 means “don’t respawn more than 3 times in 10 seconds”
pre-start exec /home/admin/init_casanovald.sh
# pre-start, post-start and pre-stop enable you
# to run stuff before or after starting a service
exec /var/lib/tomcat7/bin/catalina.sh run >> “/var/lib/tomcat7/logs/catalina.out” 2>&1
# This is where the service actually gets started. If you don’t
# redirect the messages, they end in /var/log/syslog.
No comments:
Post a Comment