5

I am currently learning upstart by playing around. I think I have understood the principle now, but I am having difficulties with the "kill timeout" stanza in upstart jobs.

For example, I have the following job (filename /etc/init/test.conf):

description "test"
start on test
console owner
kill timeout 5
task
exec /root/test

The file /root/test is a small shell script which runs forever:

while true; do o=1; done;

When doing "initctl start test", the job "test" is run and calls the script "/root/test". I can verify that by doing "initctl status test" which shows the job as running as well as by doing "ps -Alf".

Now, the "kill timeout 5" stanza should cause the job to be killed after 5 seconds. But instead, the job seems to run forever.

I would like to know if I am using and understanding the kill timeout stanza in the right way. It is an essential feature for me.

This is on Natty 11.04, but I think the question applies to other versions as well.

Thank you very much,

Binarus

Binarus
  • 810

1 Answers1

4

That's not what kill timeout does; it specifies how long to wait after sending a polite "terminate" signal for the process to exit before giving up and launching nukes.

If you want to set a process time limit in the upstart way, the easiest way is probably to have something periodically issue a timer event, and use stop on timer. Alternately (and perhaps more generally), create a wrapper program which forks a small process which sends an event after a time period, and stop on that event.

For more information and best practices, see The Upstart Cookbook.

Mark Russell
  • 7,396
geekosaur
  • 11,777