-1

I have setup MMS agent for my mongoD instances on AWS. MMS Agent is on a separate t1.micro instance. It all works fine however, every time I reboot the server I have to run sudo nohup python agent.py > agent.log 2>&1 & to start the service!!

How can I add this to service so with every reboot MMS Agent starts too!

1 Answers1

0

If you are running Ubuntu you could use the following Upstart script ( /etc/init/mms_agent.conf ):

# 
# description   "mms_agent"
# 

start on runlevel [2345]
stop on runlevel [06]

respawn
respawn limit 2 5

env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env LOGFILE=/opt/mms_agent/mms_agent.log

respawn
respawn limit 2 5

kill timeout 60

chdir /opt/mms_agent

script

  exec su -c 'python agent.py' mms_agent >> $LOGFILE 2>&1

end script
draper7
  • 111
  • 1
  • I am on Amazon Linux distro which is similar to red hat I think. Would /etc/rc.local be the place to put the command in? – user2430670 Jul 30 '13 at 23:50