-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootWeb
executable file
·105 lines (98 loc) · 2.42 KB
/
BootWeb
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
#!/bin/bash
# Title : BootWeb
# Description : BootWeb Application Server Launcher
# Authors : BootWeb by the KaraCos Team < http://www.karacos.org >
# : Cyril Gratecos < [email protected] >
# : Nicolas Karageuzian < [email protected] >
# License : The MIT License (MIT)
# Copyright (c) : <2014-2113> <The KaraCos Team>
# Date : 20140805
# Version : 0.1
# Usage : ./Bootweb --help
export BW="$( readlink -f ${BASH_SOURCE[0]} )"
export BW_ROOT="$( dirname $BW )"
# NodeJS Variables
# export NODE_PATH="${BW_ROOT}/lib/node_modules"
# Loging Variables
export LOGFILE="${BW_ROOT}/servers/${BW_SERVER}/logs/bootweb.log" # Fichier de log
export LOGLEVEL="DEBUG"
source $BW_ROOT/bootweb/functions.sh
if [ ! $( command -v node ) ]
then
export NODEJS="$BW_ROOT/bin/node-v0.10.26-linux-x64/bin/node"
else
export NODEJS=$( command -v node )
fi
if [ ! $( command -v npm ) ]
then
export NPM="$BW_ROOT/bin/node-v0.10.26-linux-x64/bin/npm"
else
export NPM=$( command -v npm )
fi
function usage {
echo "Usage: $0 {start|stop|restart|status|createserver} SERVER"
}
if [ "$#" -ge "2" ]
then
export BW_SERVER=$2
case "$1" in
start)
if [ -d "$BW_ROOT/servers/$BW_SERVER" ]
then
echo $( splashScreen )
$NODEJS $BW_ROOT/bootweb/cluster.js $@ &
#$NODEJS $BW_ROOT/bootweb/server.js $@ &
exit 0
else
$0 createserver $BW_SERVER
fi
;;
stop)
PIDFILE="$BW_ROOT/servers/$BW_SERVER/run/bootweb.pid"
if [ -f $PIDFILE ]
then
PID=$( cat $PIDFILE )
kill -s SIGINT $PID
exit 0
fi
;;
restart)
$0 stop $BW_SERVER
sleep 2
$0 start $BW_SERVER
;;
status)
exit 1
;;
npm)
PWD=$( pwd )
cd $BW_ROOT
$NPM $2 $3
echo $@
exit 0
;;
install)
doInstall
exit 0
;;
createserver)
echo "Server $BW_SERVER does not exist"
read -p "Do you want to create the server $BW_SERVER ? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
cd $BW_ROOT/servers
mkdir -p $BW_SERVER $BW_SERVER/run $BW_SERVER $BW_SERVER/datas
mkdir -p $BW_SERVER/etc $BW_SERVER/logs $BW_SERVER/home $BW_SERVER/tmp
echo "server $BW_SERVER created"
fi
exit 0
;;
*)
usage
exit 1
;;
esac
else
usage
fi