Seems you don't understand how scripts stanzas works.
pre-start stanza
pre-start script
echo 'Starting myscript Daemon\n'
end script
This script start before your main scrips, if it fails, the start sequence will fails. This is normally used for some adhoc operations that will allow the first script to start, these are not daemon-like (continuously running at background). Example:
pre-start script
/lib/init/apparmor-profile-load usr.sbin.avahi-daemon
end script
script
opts="-D"
[ -e "/etc/eucalyptus/avahi-daemon.conf" ] && opts="${opts} -f /etc/eucalyptus/avahi-daemon.conf"
exec avahi-daemon ${opts}
end script
As you can see, the apparmor profile is first load from the DBus (yeah, kind of awkward if you don't know the backend of Ubuntu) then starts the service as intended. This operation is designed for process that die once executed.
script stanza
script
exec /foo/bar/myscript-start.sh
end script
This is the only part of your program that needs to run continuously and upstart has to track it's PID. This process dies when you stop the script.
post-stop stanza
post-stop script
echo 'and apparently we are done....'
end script
This stanzas are designed as a kind of a cleanup process. It will be executed once the main script dies gracefully. For example, apport:
post-stop script
# Check for a hung resume. If we find one try and grab everything
# we can to aid in its discovery
if [ -e /var/lib/pm-utils/status ]
then
ps -wwef > /var/lib/pm-utils/resume-hang.log
fi
if [ "`dd if=/proc/sys/kernel/core_pattern count=1 bs=1 2>/dev/null`" != "|" ]
then
exit 1
else
echo 0 > /proc/sys/fs/suid_dumpable
echo "core" > /proc/sys/kernel/core_pattern
fi
end script
It tries to detect a resume from sleep that was not successful and starts preparations for detect the next hang so it can produce a useful report (yeah, is complicated again, but that was the most simple script I found apart ufw
which is oversimplified). As you can see each process dies by itself since it could block the shutdown of the system (in such cases there's also a script that sends TERM
and KILL
signals to hanged process).
Bottom line, what you are experiencing is perfectly normal and is the desired behavior of upstart.