Mercurial > pub > site.implab
diff serve.pl @ 0:aac1085b256d
initial commit
author | cin |
---|---|
date | Sat, 15 Mar 2014 00:34:33 +0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/serve.pl Sat Mar 15 00:34:33 2014 +0400 @@ -0,0 +1,50 @@ +#!/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; \ No newline at end of file