annotate serve.pl @ 2:a7a3e4f626ff

sync
author sergey
date Wed, 07 May 2014 12:35:55 +0400
parents aac1085b256d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
aac1085b256d initial commit
cin
parents:
diff changeset
1 #!/usr/bin/perl
aac1085b256d initial commit
cin
parents:
diff changeset
2 use strict;
aac1085b256d initial commit
cin
parents:
diff changeset
3 use warnings;
aac1085b256d initial commit
cin
parents:
diff changeset
4 use POSIX qw(setsid);
aac1085b256d initial commit
cin
parents:
diff changeset
5
aac1085b256d initial commit
cin
parents:
diff changeset
6 my ($pidApache,$pidMysql,$pidTailf);
aac1085b256d initial commit
cin
parents:
diff changeset
7
aac1085b256d initial commit
cin
parents:
diff changeset
8 print "starting apache\n";
aac1085b256d initial commit
cin
parents:
diff changeset
9 unless($pidApache = fork()) {
aac1085b256d initial commit
cin
parents:
diff changeset
10 setsid();
aac1085b256d initial commit
cin
parents:
diff changeset
11 exec('/usr/sbin/httpd2 -d . -f httpd.conf -DNO_DETACH -DFOREGROUND');
aac1085b256d initial commit
cin
parents:
diff changeset
12 }
aac1085b256d initial commit
cin
parents:
diff changeset
13
aac1085b256d initial commit
cin
parents:
diff changeset
14 print "starting mysql\n";
aac1085b256d initial commit
cin
parents:
diff changeset
15 unless($pidMysql = fork()) {
aac1085b256d initial commit
cin
parents:
diff changeset
16 #setsid();
aac1085b256d initial commit
cin
parents:
diff changeset
17 open STDERR, '>mysql.log';
aac1085b256d initial commit
cin
parents:
diff changeset
18 open STDOUT, '>mysql.log';
aac1085b256d initial commit
cin
parents:
diff changeset
19 exec('/usr/sbin/mysqld --defaults-file=./my.cnf');
aac1085b256d initial commit
cin
parents:
diff changeset
20 }
aac1085b256d initial commit
cin
parents:
diff changeset
21
aac1085b256d initial commit
cin
parents:
diff changeset
22 print "press any key to stop\n";
aac1085b256d initial commit
cin
parents:
diff changeset
23 print "opening apache log\n";
aac1085b256d initial commit
cin
parents:
diff changeset
24 unless($pidTailf = fork()) {
aac1085b256d initial commit
cin
parents:
diff changeset
25 #setsid();
aac1085b256d initial commit
cin
parents:
diff changeset
26 exec('/usr/bin/tailf httpd.log');
aac1085b256d initial commit
cin
parents:
diff changeset
27 }
aac1085b256d initial commit
cin
parents:
diff changeset
28
aac1085b256d initial commit
cin
parents:
diff changeset
29 getc;
aac1085b256d initial commit
cin
parents:
diff changeset
30
aac1085b256d initial commit
cin
parents:
diff changeset
31 print "SHUTDOWN\n";
aac1085b256d initial commit
cin
parents:
diff changeset
32
aac1085b256d initial commit
cin
parents:
diff changeset
33 print "shutdown apache ($pidApache)\n";
aac1085b256d initial commit
cin
parents:
diff changeset
34 kill 28, $pidApache;
aac1085b256d initial commit
cin
parents:
diff changeset
35 waitpid $pidApache, 0;
aac1085b256d initial commit
cin
parents:
diff changeset
36 print "apache exited\n";
aac1085b256d initial commit
cin
parents:
diff changeset
37
aac1085b256d initial commit
cin
parents:
diff changeset
38 print "shutdown mysql ($pidMysql)\n";
aac1085b256d initial commit
cin
parents:
diff changeset
39 kill 15, $pidMysql;
aac1085b256d initial commit
cin
parents:
diff changeset
40 waitpid $pidMysql, 0;
aac1085b256d initial commit
cin
parents:
diff changeset
41 print "mysql exited\n";
aac1085b256d initial commit
cin
parents:
diff changeset
42
aac1085b256d initial commit
cin
parents:
diff changeset
43
aac1085b256d initial commit
cin
parents:
diff changeset
44 print "closing log ($pidTailf)\n";
aac1085b256d initial commit
cin
parents:
diff changeset
45 kill 9, $pidTailf;
aac1085b256d initial commit
cin
parents:
diff changeset
46 waitpid $pidTailf, 0;
aac1085b256d initial commit
cin
parents:
diff changeset
47
aac1085b256d initial commit
cin
parents:
diff changeset
48 print "done\n";
aac1085b256d initial commit
cin
parents:
diff changeset
49
aac1085b256d initial commit
cin
parents:
diff changeset
50 exit;