LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   CentOS-6.2 & Upstart: Alternative to starting process with runlevel @ boot-up (https://www.linuxquestions.org/questions/linux-server-73/centos-6-2-and-upstart-alternative-to-starting-process-with-runlevel-%40-boot-up-4175416364/)

jb60606 07-12-2012 11:26 AM

CentOS-6.2 & Upstart: Alternative to starting process with runlevel @ boot-up
 
CentOS release 6.2
upstart-0.6.5-10.el6.x86_64

Can anyone recommend an alternative event to runlevel change when auto-starting a process at boot up?

I've written the following upstart script to respawn a process after reboot (and gracefully shutdown before system shutdown/reboot). It seems to work fine (though please let me know if you recommend any improvements).

Quote:

start on stopped rc RUNLEVEL=4
stop on starting rc RUNLEVEL=[!4]

kill timeout 300

respawn
respawn limit 2 30

script
. /opt/####/env.sh
export ####_####RAWA_NIC=eth1
export ####_####RAWB_NIC=eth2
export ####_####_OUTBOUND_NIC=eth0
exec /opt/####/bin/LINUX-2.6/rhel/gcc41/64/#### -l /opt/ronin/####/configs -c ####-mc-server-####.xml > /opt/####_logs/run-mc-server-####.sh 2>&1
end script
Granted, I don't know a great deal about the Linux boot process, but I've tried the following without success and our admins are getting tired of me constantly rebooting the expensive server :)

#start on started networking
#start on startup
#start on (local-filesystems)
#start on started net-device-up IFACE=lo
#start on started net-device-up IFACE=eth1
#start on started net-device-up IFACE=eth2
#start on started net-device-up IFACE=eth0

Farzan Mufti 07-12-2012 11:43 AM

CentOS/Redhat service start and stop
 
Are you trying to start the service upstart?
I am not very clear but I am guessing you want to get the effect of command
Code:

service upstart start
Except that you want it to run and end at certain runlevels. Am I correct?

On CentOS you can do
Code:

chkconfig --level 35 service_name on
And it would make the service start and stop gracefully for runlevels 3 and 5.
In particular you may issue command
Code:

chkconfig --level 35 upstart on
This would start and stop the service named upstart for you when the systems enters or exits run levels 3 and 5.


From: Farzan Jameel Mufti MS (CS, Theoretical Math), MEng (Internetworking)

jb60606 07-12-2012 11:55 AM

Hi Farzan,

I'm not trying to start Upstart - Upstart is the replacement for init and is probably the first process launched by the kernel automatically. I'm trying to have Upstart start my script after any event other than a runlevel change.

The default runlevel of this machine is runlevel 4 and as you can see in the script quoted above, requires 3 network interfaces (eth0, eth1, eth2). So it would have to be triggered by any event after runlevel4 is reached and after all network interfaces are brought online.

Thanks

Farzan Mufti 07-12-2012 12:08 PM

Sorry, I keep my knowledge up to date but did not know that init has been replaced. Well, I issued command pstree on my CentOS 6.0 and it still shows me init as the first process.

In any case, my answer above should still solve your problem. I would not try to mess with the start up script of any process. You still need to know chkconfig command and instead of --level 35 you would need --level 4. If you can name a few services that you would need to start and stop I can tell you the commands.

Apart, you can try the utility
ntsysv


Hope this helps.


From: Farzan Jameel Mufti MS (CS, Theoretical Math), MEng (Internetworking)

lithos 07-12-2012 03:12 PM

Hi,

what about starting the script after all the services have started on reboot,
from "rc.local" ?
A sudo & su from rc.local example.

good luck


All times are GMT -5. The time now is 03:26 AM.