LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 01: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, 01:55 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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, 03: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 04:38 AM.
 
Old 12-21-2007, 04:32 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

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

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


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:03 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
Open Source Consulting | Domain Registration