LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-20-2007, 02:38 AM   #1
c_golan
LQ Newbie
 
Registered: Oct 2007
Posts: 7

Rep: Reputation: 0
Daemons and init script question


I have an executable (for example foo.exe) which listen to a port. This executable gets the port number as a parameter (only two ports are valid). Simultaneously two instances of the executable can run (each listen to a different port).
I tought using two different init scripts,different only in the port number they are passing to the executable.
My question:
what is the syntax of passing the parameter to the executable (the call to daemon - i'm using /etc/rc.d/init.d/functions)?

Please pay attention to the fact that I need also the ability to use stop for stopping the daemon but only the instance with the specific parameter (as the second one if running should keep running).

Thanks in advance
 
Old 12-20-2007, 02:55 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Initscripts often source an initscript config file in /etc/sysconfig, and there's nothing against making your own if it doesn't, so if you use a slightly different (initscript and) configname for the second instance you could source it with ". /etc/sysconfig/${daemonname}_one" in the initscript, use (example) "PORT=3000000" in "/etc/sysconfig/${daemonname}_one" and then use the $PORT variable in the initscript where it should be supplied. Don't forget to use chkconfig to add symlinks for runlevels.
 
Old 12-20-2007, 04:07 AM   #3
c_golan
LQ Newbie
 
Registered: Oct 2007
Posts: 7

Original Poster
Rep: Reputation: 0
config file

OK - Let's say I'm using the config file. When the user wants to stop the specific instance of the daemon, he uses the initscript with the parameter "stop" and the daemon is "killed" according to the pid file.
But the problem is with the "status" - If I need to check if the specific instance is up, how should I check it only for the specific instance? Relying only on the specific pid or lock file is not good enough, since when the instance crashed for some reason, these files are not deleted altought the instance is down.

Any ideas?

Thanks

Last edited by c_golan; 12-20-2007 at 05:38 AM.
 
Old 12-21-2007, 05:32 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
How about reworking the status to use 'pgrep -f' to find the commandline that includes $PORT? I know it works for me.
 
Old 12-23-2007, 12:58 AM   #5
c_golan
LQ Newbie
 
Registered: Oct 2007
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks. I'll try it.
 
  


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
script init.d anna611 Linux - Newbie 9 11-28-2007 01:22 PM
Daemons question c_golan Linux - Newbie 2 10-07-2007 04:23 AM
need help with init script batymahn Linux - Server 1 08-23-2007 12:12 PM
Daemons and Server Load question RavenLX Programming 4 08-08-2007 09:25 PM
simple security question about init script java8964 Linux - Security 2 04-09-2003 08:43 PM


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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration