Permalink
Browse files

do not pass the --id option if the default id is used

The default id in the code is represented as the string "default". If
the --id option passes default to set the id, it becomes the atom
default which of course differs from the string "default". By not
using --id to specify the default id, we get the value "default" as
the default.

Make sure ids passed in via the --id option that yaws_sup.erl sees as
atoms are converted to lists. This matches what's done for other
options involving ids such as --check and --stop.

Other changes in this commit make sure that the $HOME/.yaws/yaws/ID
path is used consistently across the code and documentation, and also
a couple minor whitespace/indentation cleanups.
  • Loading branch information...
1 parent 9c63c94 commit d63642ede3c081a4b2533c54e3593d72d7c7cf55 @vinoski vinoski committed Dec 15, 2009
Showing with 54 additions and 45 deletions.
  1. +4 −4 include/yaws.hrl
  2. +2 −2 man/yaws.1
  3. +2 −2 man/yaws.conf.5
  4. +1 −1 scripts/freebsd/yaws.sh
  5. +8 −5 scripts/netbsd/yaws.sh
  6. +1 −1 scripts/yaws.conf.template
  7. +32 −27 scripts/yaws.template
  8. +1 −2 src/yaws_ctl.erl
  9. +2 −0 src/yaws_sup.erl
  10. +1 −1 win32/yaws.conf
View
@@ -87,10 +87,10 @@
yaws, %% server string
id = "default", %% string identifying this instance of yaws
enable_soap = false, %% start yaws_soap_srv iff true
- soap_srv_mods = [] %% a list of
- %% {{Mod, Func}, WsdlFile, Prefix } | {{Mod, Func}, WsdlFile}
- %% which will be automatically setuped
- %% while yaws_soap_srv init.
+ soap_srv_mods = [] %% a list of
+ %% {{Mod, Func}, WsdlFile, Prefix } |
+ %% {{Mod, Func}, WsdlFile}
+ %% automatically setup in yaws_soap_srv init.
}).
View
@@ -118,7 +118,7 @@ Pass STRING as an additional argument to the "erl" program.
This flag sets the id. If we're starting a daemon (or an interactive
system) it gives the Yaws server the identity ID. This means that the
server will write all internal files into the directory
-$HOME/.yaws/ID.
+$HOME/.yaws/yaws/ID.
Yaws also creates a file called
${VARDIR}/run/yaws/ctl-${ID} which contains the portnumber the daemon
@@ -151,7 +151,7 @@ Stop the daemon (called id)
.TP
\fB\--ls \fR
Lists current ids and status of all yaws servers on localhost. In practice this
-amounts to a listdir in $HOME/.yaws/yaws - and check wether the different
+amounts to a listdir in $HOME/.yaws/yaws - and check whether the different
systems who has created files there are alive.
.TP
\fB--status [--id id]\fR
View
@@ -57,7 +57,7 @@ To stop the Yaws server with id "foobar". Each Yaws server will write
its internals data into a file called $HOME/.yaws/yaws/ID where ID the
identity of the server. Yaws also creates a file called
${VARDIR}/run/yaws/ctl-${ID} which contain the portnumber where the server is
-listening for control commands. The default id is "default"
+listening for control commands. The default id is "default".
.TP
\fB include_dir = Directory\fR
@@ -483,7 +483,7 @@ the client when a certificate is requested.
\fB verify = 1 | 2 | 3\fR
Specifies the level of verification the server does on client certs.
1 means nothing, 2 means the the server will ask the client for a cert but
-not fail if the client doesn't supply a client cert, 3 means that the server
+not fail if the client does not supply a client cert, 3 means that the server
requires the client to supply a client cert.
.TP
\fB depth = Int\fR
View
@@ -24,7 +24,7 @@ stop() {
}
reload() {
- $yaws ${idarg} --hup
+ $yaws ${idarg} --hup
}
View
@@ -28,23 +28,26 @@ status_cmd="yaws_status"
reload_cmd="yaws_reload"
extra_commands="reload status"
-: ${yaws_id:=default}
+if [ -n "$yaws_id" ]
+then
+ yaws_id="--id $yaws_id"
+fi
: ${yaws_flags:=--heart}
yaws_start() {
- $yaws_command --id $yaws_id $yaws_flags --daemon
+ $yaws_command $yaws_id $yaws_flags --daemon
}
yaws_stop() {
- $yaws_command --id $yaws_id --stop
+ $yaws_command $yaws_id --stop
}
yaws_status() {
- $yaws_command --id $yaws_id --status
+ $yaws_command $yaws_id --status
}
yaws_reload() {
- $yaws_command --id $yaws_id --hup
+ $yaws_command $yaws_id --hup
}
if [ -f /etc/rc.subr -a -f /etc/rc.conf ]
@@ -83,7 +83,7 @@ auth_log = true
# When we're running multiple yaws systems on the same
# host, we need to give each yaws system an individual
# name. Yaws will write a number of runtime files under
-# ${HOME}/.yaws/${id}
+# ${HOME}/.yaws/yaws/${id}
# The default value is "default"
View
@@ -81,17 +81,17 @@ help()
-debug="";
-daemon="";
-interactive="";
-trace="";
-conf="";
-runmod="";
-sname="";
-heart="";
-xpath="";
-mnesia="";
-id="default";
+debug=""
+daemon=""
+interactive=""
+trace=""
+conf=""
+runmod=""
+sname=""
+heart=""
+xpath=""
+mnesia=""
+id=""
pdist=""
erlarg=""
kpoll=true
@@ -104,10 +104,11 @@ wait_started() {
while [ $i -lt $count ]; do
sleep 1
i=`expr $i + 1`
- ${program} --id ${id} --status 2>&1 > /dev/null
+ idarg="--id ${id:-default}"
+ ${program} ${idarg} --status 2>&1 > /dev/null
[ $? = 0 ] && exit 0
done
- echo "No yaws system responding for id=${id}"
+ echo "No yaws system responding for id=$id"
exit 1
}
@@ -135,7 +136,7 @@ if [ "$HEART" = true ]; then
fi
fi
fi
-HEART_COMMAND="${ENV_PGM} HEART=true YAWS_HEART_RESTARTS=$restarts YAWS_HEART_START=$starttime $program "${1+"$@"}
+HEART_COMMAND="$ENV_PGM HEART=true YAWS_HEART_RESTARTS=$restarts YAWS_HEART_START=$starttime $program "${1+"$@"}
export HEART_COMMAND
while [ $# -gt 0 ]
@@ -186,7 +187,7 @@ while [ $# -gt 0 ]
conf=" -conf $1 "
shift;;
-pa|--pa)
- xpath=" ${xpath} -pa $1 "
+ xpath=" $xpath -pa $1 "
shift;;
-r|--runmod)
runmod=" -runmod $1 "
@@ -202,10 +203,12 @@ while [ $# -gt 0 ]
--stats)
ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stats";;
-load|--load)
- $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load $* ${id}
+ loadid=${id:-default}
+ $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load $* $loadid
exit 0;;
--debug-dump)
- $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl debug_dump ${id}
+ ddid=${id:-default}
+ $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl debug_dump $ddid
exit 0;;
-j|--ctltrace)
ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl trace $1"
@@ -254,9 +257,10 @@ while [ $# -gt 0 ]
erlarg="$erlarg $1 "
shift;;
-check|--check)
- mkdir ${HOME}/.yaws/ 2> /dev/null
- mkdir ${HOME}/.yaws/${ID} 2> /dev/null
- out=`exec $erl -noshell -pa ${yawsdir}${delim}ebin ${xpath} -s yaws_ctl check ${id} $*`
+ checkid=${id:-default}
+ mkdir ${HOME}/.yaws/yaws 2> /dev/null
+ mkdir ${HOME}/.yaws/yaws/$checkid 2> /dev/null
+ out=`exec $erl -noshell -pa ${yawsdir}${delim}ebin $xpath -s yaws_ctl check $checkid $*`
if [ "$?" = "0" ]; then
echo "$out"
echo "$1" ok
@@ -284,8 +288,9 @@ export YAWS_HEART_COUNT YAWS_HEART_SECS
[ -n "$call_wait_started" ] && wait_started $call_wait_started
-if [ ! -z "${ex}" ]; then
- exec ${ex} ${id}
+if [ -n "$ex" ]; then
+ [ -n "$id" ] && execid=$id || execid=default
+ exec $ex $execid
exit 0
fi
@@ -306,18 +311,18 @@ else
RUN_ERL="eval"
fi
-if [ ! -z "${id}" ]; then
- id="-yaws id ${id}"
+if [ -n "$id" ]; then
+ id="-yaws id $id"
fi
-trace="${trace} ${traceoutput}"
+trace="$trace $traceoutput"
[ "$run_erl" = "eval" ] && [ -z "$daemon" ] && [ -z "$interactive" ] && help
-XEC="${daemon} ${heart} +K ${kpoll} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${pdist} ${erlarg} ${debug} -run yaws ${trace} ${conf} ${runmod} ${mnesia} ${id}"
+XEC="$daemon $heart +K $kpoll -pa ${yawsdir}${delim}ebin $xpath $sname $pdist $erlarg $debug -run yaws $trace $conf $runmod $mnesia $id"
if [ -z "$heart" ] || [ -z "$daemon" ]; then
unset HEART_COMMAND
fi
-${RUN_ERL} "exec $erl $XEC"
+$RUN_ERL "exec $erl $XEC"
View
@@ -451,7 +451,7 @@ s_cmd(Fd, SID, Count) ->
%% List existing yaws nodes on this machine for this user
ls(_) ->
- Dir = filename:join([yaws:tmpdir(), "yaws"]),
+ Dir = filename:join([yaws:tmpdir(), "yaws"]),
case file:list_dir(Dir) of
{ok, List} ->
io:format("~-15s~-10s~-10s~n",
@@ -463,7 +463,6 @@ ls(_) ->
end, List);
_ ->
ok
-
end,
init:stop().
View
@@ -110,6 +110,8 @@ get_app_args() ->
Id = case application:get_env(yaws, id) of
undefined ->
"default";
+ {ok, Id0} when is_atom(Id0) ->
+ atom_to_list(Id0);
{ok, Id0} ->
Id0
end,
View
@@ -81,7 +81,7 @@ auth_log = true
# When we're running multiple yaws systems on the same
# host, we need to give each yaws system an individual
# name. Yaws will write a number of runtime files under
-# ${HOME}/.yaws/${id}
+# ${HOME}/.yaws/yaws/${id}
# The default value is "default"

0 comments on commit d63642e

Please sign in to comment.