Upstart documentation for CentOS 6
Don't fret over upstart
, RHEL (and thus CentOS) is migrating to systemd
for version 7. Even Ubuntu has decided to get rid of upstart (see this blog post by Mark Shuttleworth).
Related videos on Youtube
Comments
-
GoinOff almost 2 years
I am currently migrating from CentOS 5.5 to 6.4. Having fun converting /etc/inittab stuff to upstart. Ran into a lot of little problems but am getting the hang of it now. The best documentation I've found is for Ubuntu:
http://upstart.ubuntu.com/cookbook/#id416
It was helpful with various upstart issues I ran into. The only problem is that some of the ubuntu items do not work with CentOS (Can't get logger function to work but found a way around that with 'exec >/dev/kmsg 2>&1').
Is there any CentOS specific documentation out there to help with upstart scripts? CentOS needs the same document that Ubuntu has..Argg!!
Since I'm new to upstart, I'm still not sure what the best practices are. The script below seems to work great too. Any comments on it are welcome..Thx!!
Here is a script that launches TTYs for modem dialin service to the server. It can launch TTYs for modems connected by USB,Serial,Network modem bank (Digi Port Server). It uses a file maintained by an admin to specify which ttys to launch :
/etc/init/ssi-ttys.conf:
start on stopped rc RUNLEVEL=[2345] task script #-------------------------------------------------------------------- # The following exec will send the data to the kernels ring buffer. # Once the syslog daemon starts, this data will be redirected to the # system log file. So, the echo below will be written out to # /var/log/messages. Helps out a ton when you need to debug these # scripts. #-------------------------------------------------------------------- exec >/dev/kmsg 2>&1 re="^#" while read line do tty= identifier= # Proccess /etc/ssi-init-ttys.conf lines without comments if [[ ! $line =~ $re ]] then set $line tty=$1 identifier=$2 echo "Starting TTY ($tty) ($identifier) using ssi-tty.conf" #----------------------------------------------------------------- # Remember that Upstart runs every script section using /bin/sh -e. # This means that if any simple command fails, the shell will exit. # So, this is why || true is added to the start so if one of the # TTYs is already running (Which would normally cause an exit, # the loop will continue and start other TTYs without exiting. # Add || true to any system command that might return a code other # than 0. #------------------------------------------------------------------ initctl start ssi-tty TTY=$tty IDENTIFIER=$identifier || true fi done </etc/ssi-init-ttys.conf end script
/etc/init/ssi-tty.conf:
stop on runlevel [S016] respawn respawn limit 5 10 # There's an automatic limit set to this: if a process is respawned more # than 5 times within 10 seconds, it will be stopped and not restarted. # Check /var/log/messages and /var/log/mgetty.log.<tty> for error messages instance $TTY script # Regex for serial and USB ttys reg1="ttyUSB" reg2="ttyS" m_flg="" # Check for USB or serial ttys which use the -D flag for mgetty if [[ $TTY =~ $reg1 ]] || [[ $TTY =~ $reg2 ]] then # Use -D flag with mgetty for ttyUSB and ttyS ports m_flg="-D" fi exec /sbin/mgetty $m_flg $TTY $IDENTIFIER end script usage 'ssi-tty TTY=ttyX IDENTIFIER=Z - ttyX is the tty id and Z is the /etc/gettydefs identifier'
/etc/ssi-init-ttys.conf:
# Serial port TTY ttyS0 9 # USB port tty ttyUSB0 9 # Digi port tty ttyA18 9
Note: 9 indicates the appropriate /etc/gettydefs identifier to use for the tty.
-
vonbrand over 10 years