This is my first time with upstart and am using EC2.
os/upstart = aws base AMI latest version - upstart-0.6.5-13.3.13.amzn1.x86_64
I can not get the following script to launch when waiting for the network to initiate. It will work if using standard
start on runlevel [2345]
stop on runlevel [!2345]
I have also tried various combinations of
start on filesystem and net-device-up IFACE=eth0
start on filesystem and net-device-up IFACE!=lo
Any suggestions would be grateful
description "test for on network start"
start on (started network-interface
or started network-manager
or started networking)
stop on (stopping network-interface
or stopping network-manager
or stopping networking)
script
touch /home/ec2-user/myFile.txt
end script
Upstart is an event based system. For your job to execute at a correct stage it may need to wait for particular event(s) emitted by other start up job(s).
Possible solutions will differ from system to system and will depend on how upstart jobs are defined and what events they emit. It may also depend on the upstart version installed on the system.
Please note that upstart might not write it's logs to
/var/log/upstart
. Earlier versions may usesyslogd
while newer ones are more likely to write logs to/var/log/upstart
.Below solution will only work on the type of the system mentioned in the question:
On this system upstart didn't log job
echo
statements anywhere. So this part may require extra configuration.Job definition:
Test on a real EC2 instance:
Your example is realllly close.
Amazon Linux calls their networking service
network
. So if the application/service you're attempting to control with upstart requires a network connection, do this:You don't need the runlevel bits, but its not a bad idea to be able to limit the service from running depending on the run level environment.