-
Notifications
You must be signed in to change notification settings - Fork 29
/
perseo
executable file
·103 lines (90 loc) · 2.41 KB
/
perseo
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
#!/bin/bash
#
# perseo Start/Stop the PEP Proxy
#
# chkconfig: 2345 99 60
# description: perseo-fe
### BEGIN INIT INFO
# Provides: perseo
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 345
# Default-Stop: 90
# Short-Description: run perseo
# Description: Perseo is the Complex Event Process for IoT platform
### END INIT INFO
# Copyright 2014 Telefonica Investigacion y Desarrollo, S.A.U
#
# This file is part of perseo-fe.
#
# perseo-fe is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# perseo-fe is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with perseo-fe. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# iot_support at tid dot es
. /etc/rc.d/init.d/functions
PARAM=$1
NAME=perseo
EXECUTABLE=bin/${NAME}
PROXY_PATH=/opt/perseo
PROXY_USER=cep
PIDFILE=$PROXY_PATH/$NAME.pid
LOG_PATH=/var/log/perseo/perseo.log
perseo_start()
{
printf "%-50s" "Starting ${NAME}..."
cd $PROXY_PATH
if [[ -x ${EXECUTABLE} ]]; then
cd $PROXY_PATH
su $PROXY_USER -c "cd $PROXY_PATH; nohup ${EXECUTABLE} &>> $LOG_PATH & echo \$! > $PIDFILE"
chmod 644 $PIDFILE
echo "Success"
else
printf "%s\n" "Fail - missing ${EXECUTABLE} executable"
exit 1
fi
}
perseo_stop()
{
printf "%-50s" "Stopping $NAME..."
if [ -f "${PIDFILE}" ]; then
kill -9 $(cat ${PIDFILE})
rm -f ${PIDFILE}
printf "%s\n" "$(success)"
else
printf "%s\n" "$(failure)"
fi
}
perseo_status()
{
status -p ${PIDFILE} ${EXECUTABLE}
}
case ${PARAM} in
'start')
echo "Starting..."
status -p ${PIDFILE} ${EXECUTABLE} && exit 0
perseo_start
;;
'stop')
echo "Stopping..."
status -p ${PIDFILE} ${EXECUTABLE} || exit 0
perseo_stop
;;
'restart')
perseo_stop
perseo_start
;;
'status')
perseo_status
;;
esac