view serve.pl @ 0:aac1085b256d

initial commit
author cin
date Sat, 15 Mar 2014 00:34:33 +0400
parents
children
line wrap: on
line source

#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(setsid);

my ($pidApache,$pidMysql,$pidTailf);

print "starting apache\n";
unless($pidApache = fork()) {
	setsid();
	exec('/usr/sbin/httpd2 -d . -f httpd.conf -DNO_DETACH -DFOREGROUND');
}

print "starting mysql\n";
unless($pidMysql = fork()) {
	#setsid();
	open STDERR, '>mysql.log';
	open STDOUT, '>mysql.log';
	exec('/usr/sbin/mysqld --defaults-file=./my.cnf');
}

print "press any key to stop\n";
print "opening apache log\n";
unless($pidTailf = fork()) {
	#setsid();
	exec('/usr/bin/tailf httpd.log');
}

getc;

print "SHUTDOWN\n";

print "shutdown apache ($pidApache)\n";
kill 28, $pidApache;
waitpid $pidApache, 0;
print "apache exited\n";

print "shutdown mysql ($pidMysql)\n";
kill 15, $pidMysql;
waitpid $pidMysql, 0;
print "mysql exited\n";


print "closing log ($pidTailf)\n";
kill 9, $pidTailf;
waitpid $pidTailf, 0;

print "done\n";

exit;