Second instance

Clint Byrum clint at ubuntu.com
Thu May 19 01:48:09 UTC 2011


Excerpts from Daniel L. Miller's message of Wed May 18 13:34:54 -0700 2011:
> I'm trying to start two processes via one job - not having a lot of 
> success.  The documentation indicates this should be possible - I assume 
> I'm doing something stupid.  My config:
> 
> # assp - Anti-Spam Service Proxy
> #
> # assp
> 
> description     "ASSP"
> 
> start on runlevel [2345]
> stop on runlevel [!2345]
> 
> respawn
> respawn limit 3 10
> 
> chdir /opt/assp
> 
> instance primary
> exec /usr/bin/perl /opt/assp/assp.pl
> 
> instance secondary
> exec /usr/bin/perl /opt/assp/assp.pl --AsASecondary:=1
> 

Hi Daniel, 

I'm sure what you've seen is that only the second instance is started,
because these stanzas basically overwrite one another.

Instance is more for dynamic starting of multiple jobs. On Ubuntu,
its used to configure network devices in response to udev events, as
one example.

So if you just have two things to start with slightly different arguments,
you can do it several different ways. The simplest way is just to have
two job files. If you want to make sure they both use the same logic,
you can do it like this:

# assp.conf
start on starting assp-primary or starting assp-secondary

respawn
respawn limit 3 10
chdir /opt/assp

env ARGS=

instance $ARGS

exec /usr/bin/perl /opt/assp/assp.pl $ARGS

--- then ---

# assp-primary.conf
start on runlevel [2345]
task

#assp-secondary.conf
start on runlevel [2345]
env ARGS="--AsASecondary:=1"
export ARGS
task


With this, you should end up with two instances of assp, one with an
instance value of () the other with (--AsASecondary:=1)

If you need to serialize the primary/secondary, you can change
assp-secondary.conf to 'start on started assp ARGS=""'.



More information about the upstart-devel mailing list