Solved

Programs launcher/monitor

Posted on 2000-03-16
2
207 Views
Last Modified: 2013-12-27
Hi there!, I have a set of programs (1..6) let me refer them as "services" wich I need to execute all in the same shell because they use a common PATH, and in the same machine (SUN-Solaris) run the services again but with another PATH.
The status is 2 or 3 sessions within its PATH and running this services, well the problem is that I can't control (stop, restart) only 1 program inside a service because they all have the same name but in different instances.
The idea is write a program wich forks or execs this programs from a conf file, and write the PID somewhere in order to kill and restart later 1 program of a service of a session:
 Graphical explanation:

Services = {  PgmA , PgmB , PgmC,... }
Session=  { SrvA , SrvB , SrvC , ... } where SrvA={PgmA, PgmB} ...

And I will launch different Sessions within its services and programs.

0
Comment
Question by:trickle
2 Comments
 
LVL 40

Expert Comment

by:jlevie
Comment Utility
If modifying the source of your "services" is an option, the cleanest solution would be to have each of them get their pid on startup and emit it to stdout. Your start script could then get the value and save it however you wish.
0
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 200 total points
Comment Utility
I shouldn't think that even that is necessary.  When the startup program executes the service program it knows the pid.

I'll assume the startup program is written as a sh script as you mentino the shell.  In this case, the PID of the last program spawned is held in $!, so you code would look something like this:

  session_id=a
  PATH="$PATH_a" service_program_a service_args ... &
  echo "$!" > "/my/path/pid.$session_id"

though perhaps a bit more complex if you want to group the different programs together by session or something like that.

If you're doing it in C, it's a bit more tedious becouse you need to do all the fopen's and such, but you still get the pid's from the fork() return value, so it's not that bad.  I'd definitly go with shell, as you won't need an external configuration file (the script will be small enough to have all its own config inormation).
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
error while running the scirpt 24 114
llcommand 6 75
LastLogonTimeStamp Attribute 7 47
unix example issues 18 43
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now