-
Notifications
You must be signed in to change notification settings - Fork 218
/
start-volttron
executable file
·66 lines (56 loc) · 1.55 KB
/
start-volttron
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
#!/usr/bin/env bash
if [ -z "$VOLTTRON_HOME" ]
then
vhome="$HOME/.volttron"
else
vhome="$VOLTTRON_HOME"
fi
FILE="$vhome/VOLTTRON_PID"
if [ -f "$FILE" ]; then
pid=$(cat "$FILE")
if ps -p "$pid" > /dev/null 2>&1
then
echo "VOLTTRON with process id $pid is already running"
exit 1
else
echo "PID file exists but process is not running. Removing old
VOLTTRON_PID file"
rm "$FILE"
fi
fi
SCRIPT_DIR="$( cd "$( echo "${BASH_SOURCE[0]%/*}" )" && pwd )"
# Check to make sure the script is executed from the correct
# directory and that the environment has been bootstrapped.
if [ ! -e "$SCRIPT_DIR/volttron/platform" ]; then
echo "Please execute from root of volttron repository."
exit 0
fi
if [ ! -e "$SCRIPT_DIR/env/bin/volttron" ]; then
echo "Bootstrap the environment before using this script."
exit 0
fi
# Activate environment
source "$SCRIPT_DIR/env/bin/activate"
if [ "$1" = '--rotating' ]; then
echo "Starting VOLTTRON with rotatinglog.py in the background with VOLTTRON_HOME=$vhome"
volttron -L examples/rotatinglog.py > volttron.log 2>&1 &
disown
else
echo "Starting VOLTTRON verbosely in the background with VOLTTRON_HOME=$vhome"
volttron -vv -l volttron.log > volttron.log 2>&1 &
disown
fi
echo "Waiting for VOLTTRON to startup.."
count=0
while [ ! -f "$FILE" ] && [ $count -lt 60 ]
do
sleep 1
((++count))
done
if [ -f "$FILE" ]; then
echo "VOLTTRON startup complete"
exit 0
else
echo "VOLTTRON startup failed/timed out. Please check volttron.log for details"
exit 2
fi