Solved

Programs launcher/monitor

Posted on 2000-03-16
2
208 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
removing nim resources 5 54
Generate FIPS 140-2 Public Key on Unix 5 75
Search for selected keywords and its values in multiple log files 11 56
How to clone solaris 10 machine 33 131
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…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

773 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