Mercurial > pub > site.implab
comparison serve.pl @ 0:aac1085b256d
initial commit
author | cin |
---|---|
date | Sat, 15 Mar 2014 00:34:33 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:aac1085b256d |
---|---|
1 #!/usr/bin/perl | |
2 use strict; | |
3 use warnings; | |
4 use POSIX qw(setsid); | |
5 | |
6 my ($pidApache,$pidMysql,$pidTailf); | |
7 | |
8 print "starting apache\n"; | |
9 unless($pidApache = fork()) { | |
10 setsid(); | |
11 exec('/usr/sbin/httpd2 -d . -f httpd.conf -DNO_DETACH -DFOREGROUND'); | |
12 } | |
13 | |
14 print "starting mysql\n"; | |
15 unless($pidMysql = fork()) { | |
16 #setsid(); | |
17 open STDERR, '>mysql.log'; | |
18 open STDOUT, '>mysql.log'; | |
19 exec('/usr/sbin/mysqld --defaults-file=./my.cnf'); | |
20 } | |
21 | |
22 print "press any key to stop\n"; | |
23 print "opening apache log\n"; | |
24 unless($pidTailf = fork()) { | |
25 #setsid(); | |
26 exec('/usr/bin/tailf httpd.log'); | |
27 } | |
28 | |
29 getc; | |
30 | |
31 print "SHUTDOWN\n"; | |
32 | |
33 print "shutdown apache ($pidApache)\n"; | |
34 kill 28, $pidApache; | |
35 waitpid $pidApache, 0; | |
36 print "apache exited\n"; | |
37 | |
38 print "shutdown mysql ($pidMysql)\n"; | |
39 kill 15, $pidMysql; | |
40 waitpid $pidMysql, 0; | |
41 print "mysql exited\n"; | |
42 | |
43 | |
44 print "closing log ($pidTailf)\n"; | |
45 kill 9, $pidTailf; | |
46 waitpid $pidTailf, 0; | |
47 | |
48 print "done\n"; | |
49 | |
50 exit; |