multiple instances of the same script?

paul phsdv at tiscali.fr
Sun Mar 11 09:49:27 GMT 2007


Scott James Remnant wrote:
> On Sat, 2007-03-10 at 14:13 +0100, paul wrote:
>
>   
>> Can multiple instance of the same script run at the same  time?
>>
>>     
> Yes.
>
>
> Such jobs (where multiple instances may be running at any one time) can
> be declared by using the "instance" stanza in the job definition.
>
> Example:
>
> 	start on block-device-added
>
> 	instance
>
> 	script
> 	    ...
> 	end script
>
>   
> Running "stop foo" would stop all instances of it; you can stop
> individual instances by their id.
>
>   
Scott,
I am trying out the "instance" stanza in a script, for example the 
script below:
(I am using 0.3.7)

    start on block-device-added

    stop on shutdown

    instance

    pre-start script
       echo "starting instance test $1"
    end script

    post-stop script
       echo "stopping instance test $1"
    end script


The problem is when I emit a shutdown event "initctl emit shutdown" 
initcl does not return. It waits for ever.

When I comment the "instance" stanza in the script every things behaves 
as expected.

Also start show-ids hangs (script is called test)

    # start --show-ids test
    test [#20] (start) waiting
    test [#20] (start) starting
    test [#20] (start) pre-start, process 763
    test [#20] (start) spawned
    test [#20] (start) post-start
    test [#20] (start) running
    and hangs here...

Status does work:

    # status --show-ids test
    test [#15] (instance)
        [#20] (start) running
        [#23] (start) running
        [#24] (start) running
    #


Besides I see some more (same?) issues. My fs-check and network script 
are now using "instance". After boot I see with ps that the emit in udev 
does not finish. Is this a bug, or do I not understand the behavior?

      210 ?        S<s    0:00 /sbin/udevd
      395 ?        S<     0:00  \_ /sbin/udevd
      401 ?        S<     0:00  |   \_ /usr/sbin/initctl emit
    block-device-added xvda -eDEVNAME
      439 ?        S<     0:00  \_ /sbin/udevd
      440 ?        S<     0:00  |   \_ /usr/sbin/initctl emit
    network-device-added eth0
      441 ?        S<     0:00  \_ /sbin/udevd
      442 ?        S<     0:00  |   \_ /usr/sbin/initctl emit
    network-device-added lo
      443 ?        S<     0:00  \_ /sbin/udevd
      444 ?        S<     0:00      \_ /usr/sbin/initctl emit
    network-device-added tunl0

regards,
Paul



More information about the upstart-devel mailing list