I've got a script that kicks off an app for a user. The developer likes to release things in "useable by sys admins, and not users" state, so I have to make it useable for the user.
The program is basically in two parts. A server and a GUI. The script takes arguments, and based on these arguments, will export some environment variables, kick off the server, then kick off the GUI.
Up until recently, this worked fine. However, I now need to run two back ends, and two GUI's. They communicate on dfiferent ports, and if I start everything up manually from the terminal, there is no problem. However, if I run the script twice, the second instance will kill the first instance. What I think is happening, is the 2nd server process is killing the first (and in turn, the GUI).
Since I can start two servers and two GUI's manually, all fingers are pointing to my script. I don't know too much about kicking off multiple system calls from a single perl script (like if it's a good or bad idea) so I'm a bit at a loss. Any help is appreciated.
Here's a very dumbed down version of the code. It should suffice.
#!/usr/bin/perl
use strict;
use warnings;
my $server = $ARGV[0];
my $client = $ARGV[1];
my $display = $ARGV[2];
my $variable = $ARGV[3];
$ENV{"DISPLAY"} = $display . ":0.0";
my $bin = "/usr/local/bin/";
my $port = "2222" . ( $variable + 1 );
$ENV{"PORT"} = $port;
#Start the server
my $server_path = $bin . $server;
system "$server_path &";
sleep 2;
# Start up the client
my $client_path = $bin . $client;
system "$client_path";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.