CentOS 6 and upstart
The new CentOS 6 comes with Upstart, replacing init. I am trying to convert an /etc/inittab file to the new upstart format. This particular server only has 15 or so inittab entries, however, other servers have >30. We are mainly wanting the 'respawn' part of inittab and upstart. However, I have been reading all the upstart documentation I can find, (which is pretty much ALL based on Ubuntu, and apparently on an older version of upstart) and not getting anywhere. I can create a config file (lets call it /etc/init/test.conf). The file contains this (note, anonymized)
start on runlevel [345]
stop on starting shutdown
respawn
#Comment about what it does
exec su -c "/usr/bin/ssh -2CNL 11111:127.0.0.1:11111 10.10.1.1" username
If I issue a initctl reload-configuration
the job is recognized. I can start it by calling initctl start test
and the job will start.
However, this won't work on a reboot, only manually. I have tried modifying the start command to the following, all with no luck
start on started
start on (local-filesystems and net-device-up IFACE!=lo)
start on net-device-up IFACE=eth0
and about a dozen other ways I could see mentioned in different examples. none seem to start the script. (test.conf, like all the other files in this folder, are owned by root, and 644)
Am I missing something glaringly obvious?
I found a very, very, very helpful upstart script for people that are having problems in the future. Put this into /etc/init/
# /etc/init/debug.conf
start on ( starting JOB!=debug \
or started JOB!=debug \
or stopping JOB!=debug \
or stopped JOB!=debug )
script
exec 1>>/tmp/log.file
echo -n "$UPSTART_JOB/$UPSTART_INSTANCE ($0):$$:`date`:"
echo "Job $JOB/$INSTANCE $UPSTART_EVENTS. Environment was:"
env
echo
end script
This script basically logs all jobs that start or stop. I have found that CentOS 6 does not 'emit' anything about runlevels. (nor some of the other common events I had tried.'). Looking the log file that debug job creates in /tmp/log.file was very helpful. By changing the start of my script from:
start on runlevel [345]
to
start on started sshd
all my jobs appear to start up correctly. This was a pain in the rear, since every example I found used the former syntax..
Sorry for necroposting, but I managed to solve this problem by using the following:
start on stopped rc RUNLEVEL=[345]
"stopped" is not a typo -- rc seems to stop upon entering a runlevel.
This is what I did (CentOS 6, Upstart 0.6.5) to debug respawn issues. In a different terminal, do
sudo initctl log-priority debug
sudo tail -F /var/log/messages