-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver
executable file
·110 lines (100 loc) · 2.13 KB
/
server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/bash
##
# Originally from https://github.com/febbraro/dotfiles/blob/master/bin/server
##
MYSQL="/opt/boxen/homebrew/bin/mysql.server"
NGINX="/usr/local/sbin/nginx"
NGINXPID="/usr/local/var/run/nginx.pid"
PHPFPMPID="/usr/local/var/run/php-fpm.pid"
PHPFPM="/usr/local/sbin/php-fpm --fpm-config /usr/local/etc/php/5.3/php-fpm.conf --pid $PHPFPMPID"
REDIS="/usr/local/bin/redis-server /usr/local/etc/redis.conf"
REDISPID="/usr/local/var/run/redis.pid"
function mysql() {
case $1 in
"start" )
$MYSQL start
;;
"stop" )
$MYSQL stop
;;
"status" )
sudo ps aux | grep mysql
;;
"restart" )
$MYSQL restart
;;
* )
echo "Valid commands for mysql: start | stop | restart | status"
;;
esac
}
function nginx() {
case $1 in
"start" )
echo "Starting nginx ..."
sudo $NGINX
;;
"stop" )
echo "Stopping nginx ..."
sudo kill -SIGQUIT `cat $NGINXPID`
;;
"status" )
sudo ps aux | grep ngnix;;
"restart" )
nginx stop
nginx start
;;
* )
echo "Valid commands for nginx: start | stop | restart | status";;
esac
}
function php() {
case $1 in
"start" )
echo "Starting php-pfm ..."
$PHPFPM
;;
"stop" )
echo "Stopping php-pfm ..."
sudo kill -SIGQUIT `cat $PHPFPMPID`
;;
"status" )
sudo ps aux | grep php-pfm;;
"restart" )
php stop
php start
;;
* )
echo "Valid commands for php: start | stop | restart | status";;
esac
}
function redis() {
case $1 in
"start" )
$REDIS
echo "Redis has started"
;;
"stop" )
sudo kill -SIGQUIT `cat $REDISPID`
echo "Redis has stoped"
;;
"status" )
sudo ps aux | grep redis;;
"restart" )
redis stop
redis start
;;
* )
echo "Valid commands for redis: start | stop | restart | status";;
esac
}
action=$1
service=$2
if [ -n "$service" ]
then
$service $action
else
mysql $action
nginx $action
php $action
fi