Skip to content
This repository
Newer
Older
100755 309 lines (282 sloc) 9.678 kb
21abc5ba »
2002-02-11 Initial revision
1 #!/bin/sh
f6a5b932 »
2004-03-21 ""
2
28e4c738 »
2003-09-08 first attempt to run properly under cygwin
3 yawsdir="%yawsdir%"
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
4 vardir="%vardir%"
28e4c738 »
2003-09-08 first attempt to run properly under cygwin
5 erl="%erl%"
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
6 run_erl="%run_erl%"
7 to_erl="%to_erl%"
8
28e4c738 »
2003-09-08 first attempt to run properly under cygwin
9 case `uname` in
10 CYGWIN*)
46079901 »
2008-05-25 cygwin support
11 yawsdir=`cygpath -m $yawsdir`
0be3c7e8 »
2008-02-14 untabified all of yaws
12 werl="%werl%"
46079901 »
2008-05-25 cygwin support
13 delim=/;;
28e4c738 »
2003-09-08 first attempt to run properly under cygwin
14 *)
15 delim=/
16 esac
21abc5ba »
2002-02-11 Initial revision
17
18
844fe5ab »
2002-06-20 Added support for the '-heart' switch.
19 ENV_PGM=`which env`
20
21
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
22
21abc5ba »
2002-02-11 Initial revision
23 help()
24 {
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
25 echo "usage: "
26 echo ""
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
27 echo
c9cd3043 »
2008-02-14 git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk…
28 echo " yaws -i | --interactive -- interactive (no daemon) mode"
29 echo " yaws -w | --winteractive -- cygwin interactive (werl) "
30 echo " yaws --daemon -- daemon mode"
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
31
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
32 echo ""
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
33
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
34 echo ""
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
35 echo " Auxiliary flags for the daemon: "
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
36 echo " --id Id -- set system id"
37 echo " --debug -- debug mode "
38 echo " --conf File -- set config file"
39 echo " --tracetraf -- trace traffic"
40 echo " --tracehttp -- trace http traffic"
41 echo " --traceout -- trace output to stdout"
42 echo " --version -- print version"
43 echo " --pa path -- add load path"
44 echo " --mnesiadir dir -- start Mnesia in dir"
45 echo " --proto_dist Mod -- use Mod for distrib"
46 echo " --sname xxx -- start with sname xxx"
47 echo " --name xxx -- start with name xxx"
48 echo " --runmod mod -- call mod:start/0 at startup"
49 echo " --heart -- auto restart yaws if it crashes"
50 echo " --heart-restart=C,T -- allow C heart restarts in T seconds"
51 echo " --erlarg X -- pass argument X to $erl"
52 echo " --setcookie X -- set an erlang cookie"
53 echo " --run_erl X -- use run_erl with pipe-id X"
54 echo " --to_erl X -- connect to pipe-id X"
55 echo " --disable-kpoll -- pass +K false to erlang"
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
56 echo ""
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
57
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
58 echo "ctl functions ... "
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
59 echo " yaws --hup [--id ID] -- hup the daemon, reload conf"
60 echo " yaws --stop [--id ID] -- stop the daemon "
61 echo " yaws --debug-dump [--id ID] -- produce a debug dump "
62 echo " yaws --status [--id ID] -- query the daemon status "
63 echo " yaws --load Modules -- load modules "
64 echo " yaws --ls -- list Yaws nodes and their status"
65 echo " yaws --ctltrace traffic|http -- toggle trace of running daemon"
66 echo " yaws --check YawsFile [IncDirs] -- test compile File "
67 echo " yaws --wait-started[=secs] [--id ID] -- wait for daemon to be ready"
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
68 exit 1
21abc5ba »
2002-02-11 Initial revision
69 }
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
70
71
21abc5ba »
2002-02-11 Initial revision
72
22fd7887 »
2002-06-17 Added the '-r <Mod>' switch.
73 debug="";
38fb85e6 »
2002-04-30 ""
74 daemon="";
75 interactive="";
22fd7887 »
2002-06-17 Added the '-r <Mod>' switch.
76 trace="";
77 conf="";
78 runmod="";
ab3a6d02 »
2002-06-19 Added the '-sname <Node>' switch to the yaws script
79 sname="";
844fe5ab »
2002-06-20 Added support for the '-heart' switch.
80 heart="";
767ff082 »
2004-03-10 added -pa switch to the yaws start script
81 xpath="";
c7c87a4c »
2003-08-25 -sname and mnesia flag added to start script
82 mnesia="";
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
83 id="default";
4d59534e »
2005-05-18 ""
84 pdist=""
37e9d70b »
2005-06-07 -erlarg patch by Fredrik Thulin
85 erlarg=""
a90bd689 »
2009-01-27 added kpoll as default
86 kpoll=true
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
87 call_wait_started=""
ddf3bee5 »
2009-01-08 preparing for 1.78
88 program=$0
89
90 wait_started() {
91 i=0
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
92 count=$1
93 while [ $i -lt $count ]; do
ddf3bee5 »
2009-01-08 preparing for 1.78
94 sleep 1
95 i=`expr $i + 1`
96 ${program} --id ${id} --status 2>&1 > /dev/null
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
97 [ $? = 0 ] && exit 0
ddf3bee5 »
2009-01-08 preparing for 1.78
98 done
99 echo "No yaws system responding for id=${id}"
100 exit 1
101 }
102
6949c22b »
2009-01-29 set HEART_COMMAND to allow a maximum of 5 restarts within any 60 seco…
103 now=`date -u +%s`
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
104 restarts=1
105 starttime=$now
6949c22b »
2009-01-29 set HEART_COMMAND to allow a maximum of 5 restarts within any 60 seco…
106 if [ "$HEART" = true ]; then
107 # we were restarted by heart, make sure we haven't reached our restart count
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
108 # if we get $YAWS_HEART_COUNT restarts within $YAWS_HEART_SECS seconds, we
109 # exit completely
110 # if both are 0, disable restart checking and just always restart
111 if [ $YAWS_HEART_COUNT -ne 0 -o $YAWS_HEART_SECS -ne 0 ]; then
112 timediff=`expr $now - $YAWS_HEART_START`
113 if [ $timediff -le $YAWS_HEART_SECS ]; then
114 if [ $YAWS_HEART_RESTARTS -eq $YAWS_HEART_COUNT ]; then
115 echo $YAWS_HEART_COUNT restarts attempted within $YAWS_HEART_SECS seconds, exiting
116 exit 1
117 else
118 # we haven't reached the restart max count yet, but we're still
119 # within the $YAWS_HEART_SECS second window so increment the counter
120 # but keep the same start time
121 restarts=`expr $YAWS_HEART_RESTARTS + 1`
122 starttime=$YAWS_HEART_START
123 fi
6949c22b »
2009-01-29 set HEART_COMMAND to allow a maximum of 5 restarts within any 60 seco…
124 fi
125 fi
126 fi
127 HEART_COMMAND="${ENV_PGM} HEART=true YAWS_HEART_RESTARTS=$restarts YAWS_HEART_START=$starttime $program "${1+"$@"}
128 export HEART_COMMAND
129
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
130 while [ $# -gt 0 ]
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
131 do
132 arg=$1
133 shift;
134 case $arg in
135 -i|--interactive)
0be3c7e8 »
2008-02-14 untabified all of yaws
136 interactive="true";
137 debug=" -yaws debug ";
138 daemon="";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
139 -w|--winteractive)
0be3c7e8 »
2008-02-14 untabified all of yaws
140 interactive="true";
141 debug=" -yaws debug ";
142 daemon="";
143 erl=$werl;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
144 -D|--daemon)
0be3c7e8 »
2008-02-14 untabified all of yaws
145 daemon=" -detached ";;
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
146 --wait-started=*)
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
147 call_wait_started=`echo $arg | sed -e 's/--wait-started=//'`
148 num=`expr "$call_wait_started" : "([0-9]*)"`
149 if [ "$num" != "$call_wait_started" ]; then
150 echo error: argument to --wait-started is $call_wait_started, not a number
151 exit 1
152 fi;;
ddf3bee5 »
2009-01-08 preparing for 1.78
153 --wait-started)
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
154 call_wait_started=6;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
155 -d|--debug)
0be3c7e8 »
2008-02-14 untabified all of yaws
156 debug=" -boot start_sasl -yaws debug ";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
157 -t|--tracetraf)
0be3c7e8 »
2008-02-14 untabified all of yaws
158 trace=" -yaws trace traffic ";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
159 -T|--tracehttp)
0be3c7e8 »
2008-02-14 untabified all of yaws
160 trace=" -yaws trace http ";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
161 -I|--id)
0be3c7e8 »
2008-02-14 untabified all of yaws
162 id=$1
163 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
164 -x|--traceout)
0be3c7e8 »
2008-02-14 untabified all of yaws
165 traceoutput=" -yaws traceoutput ";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
166 --trace)
0be3c7e8 »
2008-02-14 untabified all of yaws
167 traceoutput=" -yaws traceoutput ";
168 trace=" -yaws trace traffic ";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
169 -M|--mnesiadir)
91a50183 »
2008-02-28 quote patch for mnesiadir by Richard Bucker
170 mnesia=" -mnesia dir '\"$1\"' -run mnesia start"
0be3c7e8 »
2008-02-14 untabified all of yaws
171 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
172 -c|--conf)
0be3c7e8 »
2008-02-14 untabified all of yaws
173 conf=" -conf $1 "
174 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
175 -pa|--pa)
0be3c7e8 »
2008-02-14 untabified all of yaws
176 xpath=" ${xpath} -pa $1 "
177 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
178 -r|--runmod)
0be3c7e8 »
2008-02-14 untabified all of yaws
179 runmod=" -runmod $1 "
180 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
181 -h|--hup)
0be3c7e8 »
2008-02-14 untabified all of yaws
182 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl hup";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
183 -s|--stop)
0be3c7e8 »
2008-02-14 untabified all of yaws
184 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stop";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
185 -ls|--ls)
0be3c7e8 »
2008-02-14 untabified all of yaws
186 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl ls";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
187 -S|--status)
0be3c7e8 »
2008-02-14 untabified all of yaws
188 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
189 -load|--load)
0be3c7e8 »
2008-02-14 untabified all of yaws
190 $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load ${id} $*
191 exit 0;;
5207102c »
2008-05-17 Added debug dump functionality
192 --debug-dump)
193 $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl debug_dump ${id}
194 exit 0;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
195 -j|--ctltrace)
0be3c7e8 »
2008-02-14 untabified all of yaws
196 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl trace $1"
197 shift;;
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
198 -v|--version)
0be3c7e8 »
2008-02-14 untabified all of yaws
199 exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws printversion;
200 exit 0;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
201 --sname|-sname)
0be3c7e8 »
2008-02-14 untabified all of yaws
202 sname=" -sname $1 "
203 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
204 -name|--name)
0be3c7e8 »
2008-02-14 untabified all of yaws
205 sname=" -name $1 "
206 shift;;
a90bd689 »
2009-01-27 added kpoll as default
207 --disable-kpoll)
208 kpoll=false;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
209 -heart|--heart)
0be3c7e8 »
2008-02-14 untabified all of yaws
210 heart=" -heart ";;
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
211 --heart-restart=*)
212 vals=`echo $arg | sed -e 's/--heart-restart=//'`
213 saveifs="$IFS"
214 IFS=,
215 var='YAWS_HEART_COUNT'
216 for v in $vals; do
217 eval "$var=$v"
218 var='YAWS_HEART_SECS'
219 done
0e5ebd22 »
2009-04-13 improved checking of --heart-restart arguments
220 num=`expr "$YAWS_HEART_COUNT" : '\([0-9]*\)'`
221 if [ -z "$num" -o "$num" != "$YAWS_HEART_COUNT" ]; then
222 echo error: count argument to --heart-restart is '"'$YAWS_HEART_COUNT'"': not a number
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
223 exit 1
224 fi
0e5ebd22 »
2009-04-13 improved checking of --heart-restart arguments
225 num=`expr "$YAWS_HEART_SECS" : '\([0-9]*\)'`
226 if [ -z "$num" -o "$num" != "$YAWS_HEART_SECS" ]; then
227 echo error: time argument to --heart-restart is '"'$YAWS_HEART_SECS'"': not a number
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
228 exit 1
229 fi
230 IFS="$saveifs"
231 heart=" -heart ";;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
232 -proto_dist|--proto_dist)
0be3c7e8 »
2008-02-14 untabified all of yaws
233 pdist=" -proto_dist $1 "
234 shift;;
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
235 -setcookie|--setcookie)
236 erlarg="$erlarg -setcookie $1 "
237 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
238 -erlarg|--erlarg)
0be3c7e8 »
2008-02-14 untabified all of yaws
239 erlarg="$erlarg $1 "
240 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
241 -check|--check)
0be3c7e8 »
2008-02-14 untabified all of yaws
242 mkdir ${HOME}/.yaws/ 2> /dev/null
243 mkdir ${HOME}/.yaws/${ID} 2> /dev/null
244 out=`exec $erl -noshell -pa ${yawsdir}${delim}ebin ${xpath} -s yaws_ctl check ${id} $*`
245 if [ "$?" = "0" ]; then
246 echo "$out"
247 echo "$1" ok
248 exit 0
249 fi
250 echo "$out"
251 exit 1;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
252 --to_erl)
0be3c7e8 »
2008-02-14 untabified all of yaws
253 TO_ERL=yes
254 PIPE_DIR="${vardir}/run/yaws/pipe/$1"
255 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
256 --run_erl)
0be3c7e8 »
2008-02-14 untabified all of yaws
257 RUN_ERL=yes
258 daemon=""
259 PIPE_DIR="${vardir}/run/yaws/pipe/$1"
260 LOG_DIR="${vardir}/log/yaws/erlang-log/$1"
261 shift;;
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
262 *)
0be3c7e8 »
2008-02-14 untabified all of yaws
263 help
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
264 esac
21abc5ba »
2002-02-11 Initial revision
265 done
2ba58053 »
2009-04-13 add new --heart-restart option to allow control over heart restarts
266 YAWS_HEART_COUNT=${YAWS_HEART_COUNT:-5}
267 YAWS_HEART_SECS=${YAWS_HEART_SECS:-60}
268 export YAWS_HEART_COUNT YAWS_HEART_SECS
21abc5ba »
2002-02-11 Initial revision
269
88355a33 »
2009-01-28 * Document the --wait-started option for the yaws script
270 [ -n "$call_wait_started" ] && wait_started $call_wait_started
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
271
272 if [ ! -z "${ex}" ]; then
273 exec ${ex} ${id}
274 exit 0
275 fi
276
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
277 if [ -n "$TO_ERL" ]; then
278 $to_erl $PIPE_DIR/
279 exit 0
280 fi
281
282 if [ -n "$RUN_ERL" ]; then
283 if [ ! -d $LOG_DIR ]; then
0be3c7e8 »
2008-02-14 untabified all of yaws
284 mkdir -p $LOG_DIR
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
285 fi
286 if [ ! -d $PIPE_DIR ]; then
0be3c7e8 »
2008-02-14 untabified all of yaws
287 mkdir -p $PIPE_DIR
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
288 fi
289 RUN_ERL="$run_erl -daemon $PIPE_DIR/ $LOG_DIR"
290 else
291 RUN_ERL="eval"
292 fi
293
92bafb48 »
2006-03-09 removed the ability change userid, also stopped writing to /tmp/yaws …
294 if [ ! -z "${id}" ]; then
295 id="-yaws id ${id}"
296 fi
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
297
82d6e294 »
2003-08-25 added -x flag for tty trace and did the 1.3 release
298 trace="${trace} ${traceoutput}"
299
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
300 [ "$run_erl" = "eval" ] && [ -z "$daemon" ] && [ -z "$interactive" ] && help
301
a90bd689 »
2009-01-27 added kpoll as default
302 XEC="${daemon} ${heart} +K ${kpoll} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${pdist} ${erlarg} ${debug} -run yaws ${trace} ${conf} ${runmod} ${mnesia} ${id}"
38fb85e6 »
2002-04-30 ""
303
f22e6e8f »
2002-06-27 Fixed heart bug
304 if [ -z "$heart" ] || [ -z "$daemon" ]; then
6949c22b »
2009-01-29 set HEART_COMMAND to allow a maximum of 5 restarts within any 60 seco…
305 unset HEART_COMMAND
844fe5ab »
2002-06-20 Added support for the '-heart' switch.
306 fi
307
28972a3c »
2006-05-30 run_erl to_erl support patch from Mats Cronquist
308 ${RUN_ERL} "exec $erl $XEC"
Something went wrong with that request. Please try again.