LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 07-12-2012, 11:26 AM   #1
jb60606
LQ Newbie
 
Registered: Jul 2012
Posts: 2

Rep: Reputation: Disabled
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
 
Old 07-12-2012, 11:43 AM   #2
Farzan Mufti
LQ Newbie
 
Registered: Feb 2007
Location: USA/Canada
Distribution: Red Hat, CentOS, Scientific, Fedora, Ubuntu, SUSE, SLES
Posts: 14

Rep: Reputation: 6
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)
 
Old 07-12-2012, 11:55 AM   #3
jb60606
LQ Newbie
 
Registered: Jul 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
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
 
Old 07-12-2012, 12:08 PM   #4
Farzan Mufti
LQ Newbie
 
Registered: Feb 2007
Location: USA/Canada
Distribution: Red Hat, CentOS, Scientific, Fedora, Ubuntu, SUSE, SLES
Posts: 14

Rep: Reputation: 6
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)
 
Old 07-12-2012, 03:12 PM   #5
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
In RHEL-6.2, service not starting properly from upstart pmishra Red Hat 5 07-02-2012 12:20 AM
Upstart not working for Centos newbie14 Linux - Server 18 05-27-2012 12:09 PM
Upstart process information for rhel6 Rohit_4739 Red Hat 5 05-02-2012 12:46 PM
Problems starting runlevel 3 , redhat 7.3, "no more processes left in this runlevel" kiyoshi Linux - Software 1 06-25-2009 05:11 AM
runlevel & graphival boot Mistreated Linux - Software 2 06-02-2005 04:36 PM


All times are GMT -5. The time now is 03:09 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration