3

I want to run multiple instances of my process by passing an args to startup job:

start myapp instance1
start myapp instance2 

and so on

I want to have one upstart conf file instead of having conf files as many as instances of my app. Is it possible ?

JosiP
  • 31
  • 1
  • 3

1 Answers1

7

I realize the question is a bit old, but I'll go ahead and answer it. :)

Yes, you can do this, and you use the upstart "instance" clause to do it.

Here is a simple example (using a PHP based job in this case).

description "Async insert workers"
author      "Mike Grunder"

env SCRIPT_PATH="/path/to/my/script"

# This is the key bit
instance $N

script
    php $SCRIPT_PATH/worker.php
end script

If you see in that script, you've got an instance $N line. You specify the instance like so:

start the-job N=instance1
start the-job N=instance2

Obviously you could change N to whatever you like.

Now I'm back on my quest to figure out how to start a number of them automatically! :)

mkgrunder
  • 171
  • 1
  • 3