-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp
More file actions
executable file
·124 lines (108 loc) · 2.49 KB
/
app
File metadata and controls
executable file
·124 lines (108 loc) · 2.49 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# This script is inspired by st-exec.sh from http://stfx.eu/pharo-server/
# originally written by Sven Van Caekenberghe
function usage() {
cat <<END
Usage: $0 <command>
manage a Smalltalk server.
You *must* provide install.st and start.st files right next to the image
file.
start and stop command takes an optional pid file. By the default, the
pid file will be '${script_home}/pharo.pid'.
Commands:
install run install.sh on the image and then quit.
start run the image with start.st in background
stop stop the server.
restart restart the server
pid print the process id
END
exit 1
}
# Setup vars
script_home=$(dirname $0)
script_home=$(cd $script_home && pwd)
command=$1
image="$script_home/pharo.image"
pid_file=${2:-"$script_home/pharo.pid"}
echo $pid_file
# MacOS X
vm=/Applications/Pharo.app/Contents/MacOS/Pharo
# Other
# vm=pharo-vm-nox
# echo Working directory $script_home
function install() {
echo $vm $image install.st
$vm --headless $image install.st
}
function start() {
echo Starting $script in background
if [ -e "$pid_file" ]; then
rm -f $pid_file
fi
echo $pid_file
echo $vm $image start.st
$vm $image start.st 2>&1 >/dev/null &
echo $! >$pid_file
}
function stop() {
echo Stopping $pid_file
if [ -e "$pid_file" ]; then
pid=`cat $pid_file`
echo Killing $pid
kill $pid
rm -f $pid_file
else
echo Pid file not found: $pid_file
echo Searching in process list for $script
pids=`ps ax | grep $script | grep -v grep | grep -v $0 | awk '{print $1}'`
if [ -z "$pids" ]; then
echo No pids found!
else
for p in $pids; do
if [ $p != "$pid" ]; then
echo Killing $p
kill $p
fi
done
fi
fi
}
function restart() {
echo Restarting $script
stop
start
}
function printpid() {
if [ -e $pid_file ]; then
cat $pid_file
else
echo Pid file not found: $pid_file
echo Searching in process list for $script
pids=`ps ax | grep $script | grep -v grep | grep -v $0 | awk '{print $1}'`
if [ -z "$pids" ]; then
echo No pids found!
else
echo $pids
fi
fi
}
case $command in
install)
install
;;
start)
start
;;
stop)
stop
;;
restart)
restart
;;
pid)
printpid
;;
*)
usage
;;
esac