LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-22-2009, 09:27 PM   #1
hhilo2002
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
Stange behaviour noted when using service


Hi all,

I am using linux service to start a program. However different behaviors are observed when the service is started automatically upon startup/reboot and when the service is called manually through "service myservice start".

Script to startup my program(Name:myprog)
-----------------------------------------------------------
1 while(application is down)
2 do
3 "start my application" #script will stop here if program is running(script can still be found when i perform a "ps"
4 echo "rebooting" >> log.txt
5 done

Startup script(Name:myservice)
-----------------------------------------------------------
Simply call myprog


Via startup/reboot
------------------------------------------------------------
The application gets started however, in the event when the application crashes, the script will terminate at line 3 instead of printing out "rebooting" in log.txt. When i perform a "ps", both the script and program can no longer be found.

Via manual startup-"service myservice start"
------------------------------------------------------------
The application also gets started. However when the application crashes, the same script continue with line 4 and "rebooting" is printed in log.txt. When i perform a "ps",both the script and program can still be found.

I have done all the necessary setup, eg creating a service script(myservice) in /etc/init.d, and adding it using chkconfig.

Sorry for the long post.

Any help is greatly appreciated! Please advise.

Cheers!

Last edited by hhilo2002; 03-23-2009 at 12:19 AM.
 
Old 03-22-2009, 09:44 PM   #2
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,358

Rep: Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106Reputation: 1106
Your startup-script should not be looping. There should be no "while" logic here.

The only purpose of the scripts that are invoked to carry out a "service start|stop|restart" request should be to do exactly what is requested of them... once. It is not their responsibility to do: "while my application is down..."

Other system services are responsible for observing when and if a service is running, and to determine that it should be restarted.

Take an existing example of such a script and pattern your work after it exactly. Don't add anything to it, and don't take anything away.
 
Old 03-22-2009, 10:28 PM   #3
hhilo2002
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Just to clarify my earlier post.

Script to startup my program(Name: myprog)
-----------------------------------------------------------
1 while(application is down)
2 do
3 "start my application" #script will stop here if program is running(script can still be found when i perform a "ps"
4 echo "rebooting" >> log.txt
5 done

Startup script(Name: myservice)
-----------------------------------------------------------
Simply call myprog

Last edited by hhilo2002; 03-23-2009 at 12:18 AM.
 
Old 03-23-2009, 01:34 AM   #4
hhilo2002
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Original Poster
Rep: Reputation: 0
please advise..thanks
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Qmail stange 2 problem folken718 Slackware 3 02-11-2011 02:12 AM
my new project - de-noted.com acid_kewpie Linux - News 1 01-27-2007 09:54 PM
Stange kernel warnings IN=eth1 OUT= MAC=00:80:c8:4c:0e:..... humbletech99 Linux - Networking 2 05-23-2006 06:22 AM
Stange OpenBSD 3.5 error. lil_drummaboy *BSD 2 05-23-2004 06:05 PM
stange pf problem swoppe *BSD 2 11-12-2003 10:45 AM


All times are GMT -5. The time now is 03:54 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