Skip to content

Instantly share code, notes, and snippets.

@sng2c
Last active December 20, 2015 17:48
Show Gist options
  • Save sng2c/6170751 to your computer and use it in GitHub Desktop.
Save sng2c/6170751 to your computer and use it in GitHub Desktop.
Create 'autostart' directory on a directory which startall.pl is on. Each app directory must have start.sh and put or link the app directory in autostart directory. If you launch startall.pl, all of the start.sh scripts are running within each 'screen' processes.
#!/bin/sh
# An example of start.sh
./app_pkg.pl daemon -l 'http://localhost:50005'
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use File::pushd;
my @apps = <autostart/*>;
foreach my $d (@apps){
my $dir = pushd($d);
$d =~ m@([^/]+)$@;
my $name = $1;
my $res = system("screen -dmS '$name' ./start.sh");
print "$name - $res\n";
}
sleep(1);
system("screen -list");
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my @apps = <autostart/*>;
foreach my $d (@apps){
$d =~ m@([^/]+)$@;
my $name = $1;
system("screen -S '$name' -X quit");
}
system("screen -list");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment