I'm new to upstart, and I would like to know if there's a way to tell upstart to execute a specific command only at system startup, and not when the application is subsequently restarted from the command line. For example, I have the following upstart configuration:
#!upstart
description "Hello World"
author "me"
start on (local-filesystems and net-device-up)
stop on shutdown
script
export HOME="/root"
echo $$ > /var/run/hello-world.pid
exec /usr/local/bin/hello-world
end script
pre-start script
# Date format same as (new Date()).toISOString() for consistency
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] Hello World Starting" >> /var/log/hello-world.sys.log
end script
pre-stop script
rm /var/run/hello-world.pid
echo "[`date -u +%Y-%m-%dT%T.%3NZ`] Hello World Stopping" >> /var/log/hello-world.sys.log
end script
That successfully starts the application on startup. If I execute:
/sbin/start hello-world
This starts the application again: I would like to execute a specific command only when the system is started up, and not when the application is started up, like:
First execution:
- The system starts up
- Upstart is executed
- A specific system startup script is executed
- The application, hello-world, is executed
Second execution using /sbin/start hello-world
:
- Only execute application without executing the specific startup script
Is there a way for doing this?