Solved

Programs launcher/monitor

Posted on 2000-03-16
2
209 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
ID: 2624409
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
ID: 2625377
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

828 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