Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 257 lines (230 sloc) 7.267 kb
21abc5b @klacke Initial revision
authored
1 #!/bin/sh
f6a5b93 @klacke ""
authored
2
28e4c73 @klacke first attempt to run properly under cygwin
authored
3 yawsdir="%yawsdir%"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
4 vardir="%vardir%"
28e4c73 @klacke first attempt to run properly under cygwin
authored
5 erl="%erl%"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
6 run_erl="%run_erl%"
7 to_erl="%to_erl%"
8
28e4c73 @klacke first attempt to run properly under cygwin
authored
9 case `uname` in
10 CYGWIN*)
4607990 @klacke cygwin support
authored
11 yawsdir=`cygpath -m $yawsdir`
0be3c7e @klacke untabified all of yaws
authored
12 werl="%werl%"
4607990 @klacke cygwin support
authored
13 delim=/;;
28e4c73 @klacke first attempt to run properly under cygwin
authored
14 *)
15 delim=/
16 esac
21abc5b @klacke Initial revision
authored
17
18
844fe5a Added support for the '-heart' switch.
Tobbe Tornquist authored
19 ENV_PGM=`which env`
20
21
dc00e52 @klacke postvar bug by hal snyder, added yaws_api:query_url/1 added the id suppo...
authored
22
21abc5b @klacke Initial revision
authored
23 help()
24 {
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
25 echo "usage: "
26 echo ""
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
27 echo
c9cd304 @klacke git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/ya...
authored
28 echo " yaws -i | --interactive -- interactive (no daemon) mode"
29 echo " yaws -w | --winteractive -- cygwin interactive (werl) "
30 echo " yaws --daemon -- daemon mode"
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
31
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
32 echo ""
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
33
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
34 echo ""
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
35 echo " Auxiliary flags for the daemon: "
36 echo " --id Id -- set system id"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
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"
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
45 echo " --proto_dist Mod -- use Mod for distrib"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
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 " --erlarg X -- pass argument X to $erl"
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
51 echo " --setcookie X -- set an erlang cookie"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
52 echo " --run_erl X -- use run_erl with pipe-id X"
53 echo " --to_erl X -- connect to pipe-id X"
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
54 echo " --disable-kpoll -- pass +K false to erlang"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
55 echo ""
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
56
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
57 echo "ctl functions ... "
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
58 echo " yaws --hup [--id ID] -- hup the daemon, reload conf"
59 echo " yaws --stop [--id ID] -- stop the daemon "
60 echo " yaws --debug-dump [--id ID] -- produce a debug dump "
61 echo " yaws --status [--id ID] -- query the daemon status "
62 echo " yaws --load Modules -- load modules "
63 echo " yaws --ls -- list Yaws nodes and their status"
64 echo " yaws --ctltrace traffic|http -- toggle trace of running daemon"
65 echo " yaws --check YawsFile [IncDirs] -- test compile File "
66 echo " yaws --wait-started[=secs] [--id ID] -- wait for daemon to be ready"
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
67 exit 1
21abc5b @klacke Initial revision
authored
68 }
dc00e52 @klacke postvar bug by hal snyder, added yaws_api:query_url/1 added the id suppo...
authored
69
70
21abc5b @klacke Initial revision
authored
71
22fd788 Added the '-r <Mod>' switch.
Tobbe Tornquist authored
72 debug="";
38fb85e @klacke ""
authored
73 daemon="";
74 interactive="";
22fd788 Added the '-r <Mod>' switch.
Tobbe Tornquist authored
75 trace="";
76 conf="";
77 runmod="";
ab3a6d0 Added the '-sname <Node>' switch to the yaws script
Tobbe Tornquist authored
78 sname="";
844fe5a Added support for the '-heart' switch.
Tobbe Tornquist authored
79 heart="";
767ff08 added -pa switch to the yaws start script
Tobbe Tornquist authored
80 xpath="";
c7c87a4 @klacke -sname and mnesia flag added to start script
authored
81 mnesia="";
dc00e52 @klacke postvar bug by hal snyder, added yaws_api:query_url/1 added the id suppo...
authored
82 id="default";
4d59534 @klacke ""
authored
83 pdist=""
37e9d70 @klacke -erlarg patch by Fredrik Thulin
authored
84 erlarg=""
a90bd68 @klacke added kpoll as default
authored
85 kpoll=true
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
86 call_wait_started=""
ddf3bee @klacke preparing for 1.78
authored
87 program=$0
88
89 wait_started() {
90 i=0
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
91 count=$1
92 while [ $i -lt $count ]; do
ddf3bee @klacke preparing for 1.78
authored
93 sleep 1
94 i=`expr $i + 1`
95 ${program} --id ${id} --status 2>&1 > /dev/null
96 if [ $? = 0 ]; then
97 exit 0
98 fi
99 done
100 echo "No yaws system responding for id=${id}"
101 exit 1
102 }
103
21abc5b @klacke Initial revision
authored
104
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
105 while [ $# -gt 0 ]
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
106 do
107 arg=$1
108 shift;
109 case $arg in
110 -i|--interactive)
0be3c7e @klacke untabified all of yaws
authored
111 interactive="true";
112 debug=" -yaws debug ";
113 daemon="";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
114 -w|--winteractive)
0be3c7e @klacke untabified all of yaws
authored
115 interactive="true";
116 debug=" -yaws debug ";
117 daemon="";
118 erl=$werl;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
119 -D|--daemon)
0be3c7e @klacke untabified all of yaws
authored
120 daemon=" -detached ";;
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
121 --wait-started=*)
122 call_wait_started=`echo $arg | sed -e 's/--wait-started=//'`;;
ddf3bee @klacke preparing for 1.78
authored
123 --wait-started)
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
124 call_wait_started=6;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
125 -d|--debug)
0be3c7e @klacke untabified all of yaws
authored
126 debug=" -boot start_sasl -yaws debug ";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
127 -t|--tracetraf)
0be3c7e @klacke untabified all of yaws
authored
128 trace=" -yaws trace traffic ";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
129 -T|--tracehttp)
0be3c7e @klacke untabified all of yaws
authored
130 trace=" -yaws trace http ";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
131 -I|--id)
0be3c7e @klacke untabified all of yaws
authored
132 id=$1
133 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
134 -x|--traceout)
0be3c7e @klacke untabified all of yaws
authored
135 traceoutput=" -yaws traceoutput ";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
136 --trace)
0be3c7e @klacke untabified all of yaws
authored
137 traceoutput=" -yaws traceoutput ";
138 trace=" -yaws trace traffic ";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
139 -M|--mnesiadir)
91a5018 @klacke quote patch for mnesiadir by Richard Bucker
authored
140 mnesia=" -mnesia dir '\"$1\"' -run mnesia start"
0be3c7e @klacke untabified all of yaws
authored
141 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
142 -c|--conf)
0be3c7e @klacke untabified all of yaws
authored
143 conf=" -conf $1 "
144 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
145 -pa|--pa)
0be3c7e @klacke untabified all of yaws
authored
146 xpath=" ${xpath} -pa $1 "
147 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
148 -r|--runmod)
0be3c7e @klacke untabified all of yaws
authored
149 runmod=" -runmod $1 "
150 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
151 -h|--hup)
0be3c7e @klacke untabified all of yaws
authored
152 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl hup";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
153 -s|--stop)
0be3c7e @klacke untabified all of yaws
authored
154 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stop";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
155 -ls|--ls)
0be3c7e @klacke untabified all of yaws
authored
156 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl ls";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
157 -S|--status)
0be3c7e @klacke untabified all of yaws
authored
158 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
159 -load|--load)
0be3c7e @klacke untabified all of yaws
authored
160 $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load ${id} $*
161 exit 0;;
5207102 @klacke Added debug dump functionality
authored
162 --debug-dump)
163 $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl debug_dump ${id}
164 exit 0;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
165 -j|--ctltrace)
0be3c7e @klacke untabified all of yaws
authored
166 ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl trace $1"
167 shift;;
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
168 -v|--version)
0be3c7e @klacke untabified all of yaws
authored
169 exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws printversion;
170 exit 0;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
171 --sname|-sname)
0be3c7e @klacke untabified all of yaws
authored
172 sname=" -sname $1 "
173 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
174 -name|--name)
0be3c7e @klacke untabified all of yaws
authored
175 sname=" -name $1 "
176 shift;;
a90bd68 @klacke added kpoll as default
authored
177 --disable-kpoll)
178 kpoll=false;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
179 -heart|--heart)
0be3c7e @klacke untabified all of yaws
authored
180 heart=" -heart ";;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
181 -proto_dist|--proto_dist)
0be3c7e @klacke untabified all of yaws
authored
182 pdist=" -proto_dist $1 "
183 shift;;
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
184 -setcookie|--setcookie)
185 erlarg="$erlarg -setcookie $1 "
186 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
187 -erlarg|--erlarg)
0be3c7e @klacke untabified all of yaws
authored
188 erlarg="$erlarg $1 "
189 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
190 -check|--check)
0be3c7e @klacke untabified all of yaws
authored
191 mkdir ${HOME}/.yaws/ 2> /dev/null
192 mkdir ${HOME}/.yaws/${ID} 2> /dev/null
193 out=`exec $erl -noshell -pa ${yawsdir}${delim}ebin ${xpath} -s yaws_ctl check ${id} $*`
194 if [ "$?" = "0" ]; then
195 echo "$out"
196 echo "$1" ok
197 exit 0
198 fi
199 echo "$out"
200 exit 1;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
201 --to_erl)
0be3c7e @klacke untabified all of yaws
authored
202 TO_ERL=yes
203 PIPE_DIR="${vardir}/run/yaws/pipe/$1"
204 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
205 --run_erl)
0be3c7e @klacke untabified all of yaws
authored
206 RUN_ERL=yes
207 daemon=""
208 PIPE_DIR="${vardir}/run/yaws/pipe/$1"
209 LOG_DIR="${vardir}/log/yaws/erlang-log/$1"
210 shift;;
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
211 *)
0be3c7e @klacke untabified all of yaws
authored
212 help
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
213 esac
21abc5b @klacke Initial revision
authored
214 done
215
88355a3 @vinoski * Document the --wait-started option for the yaws script
vinoski authored
216 [ -n "$call_wait_started" ] && wait_started $call_wait_started
dc00e52 @klacke postvar bug by hal snyder, added yaws_api:query_url/1 added the id suppo...
authored
217
218 if [ ! -z "${ex}" ]; then
219 exec ${ex} ${id}
220 exit 0
221 fi
222
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
223 if [ -n "$TO_ERL" ]; then
224 $to_erl $PIPE_DIR/
225 exit 0
226 fi
227
228 if [ -n "$RUN_ERL" ]; then
229 if [ ! -d $LOG_DIR ]; then
0be3c7e @klacke untabified all of yaws
authored
230 mkdir -p $LOG_DIR
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
231 fi
232 if [ ! -d $PIPE_DIR ]; then
0be3c7e @klacke untabified all of yaws
authored
233 mkdir -p $PIPE_DIR
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
234 fi
235 RUN_ERL="$run_erl -daemon $PIPE_DIR/ $LOG_DIR"
236 else
237 RUN_ERL="eval"
238 fi
239
92bafb4 @klacke removed the ability change userid, also stopped writing to /tmp/yaws and...
authored
240 if [ ! -z "${id}" ]; then
241 id="-yaws id ${id}"
242 fi
dc00e52 @klacke postvar bug by hal snyder, added yaws_api:query_url/1 added the id suppo...
authored
243
82d6e29 @klacke added -x flag for tty trace and did the 1.3 release
authored
244 trace="${trace} ${traceoutput}"
245
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
246 [ "$run_erl" = "eval" ] && [ -z "$daemon" ] && [ -z "$interactive" ] && help
247
a90bd68 @klacke added kpoll as default
authored
248 XEC="${daemon} ${heart} +K ${kpoll} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${pdist} ${erlarg} ${debug} -run yaws ${trace} ${conf} ${runmod} ${mnesia} ${id}"
38fb85e @klacke ""
authored
249
f22e6e8 Fixed heart bug
Johan Bevemyr authored
250 if [ -z "$heart" ] || [ -z "$daemon" ]; then
844fe5a Added support for the '-heart' switch.
Tobbe Tornquist authored
251 HEART_COMMAND="";
252 else
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
253 export HEART_COMMAND="${ENV_PGM} HEART=true \"$erl\" $XEC";
844fe5a Added support for the '-heart' switch.
Tobbe Tornquist authored
254 fi
255
28972a3 @klacke run_erl to_erl support patch from Mats Cronquist
authored
256 ${RUN_ERL} "exec $erl $XEC"
Something went wrong with that request. Please try again.