Permalink
Browse files

postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…

…pport and removed the uid stuff, added -j to control trace of a running daemon, bugfixes in the logger,

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@626 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent 767ff08 commit dc00e52699f1add1ec4720f89c73779a1d861a57 @klacke committed Mar 10, 2004
Showing with 623 additions and 334 deletions.
  1. +2 −1 include/yaws.hrl
  2. +1 −0 include/yaws_api.hrl
  3. +45 −8 man/yaws.1
  4. +19 −0 man/yaws.conf.5
  5. +5 −0 man/yaws_api.5
  6. +1 −0 scripts/Makefile
  7. +57 −34 scripts/yaws.ss
  8. +70 −30 src/yaws.erl
  9. +46 −13 src/yaws_api.erl
  10. +3 −9 src/yaws_compile.erl
  11. +9 −1 src/yaws_config.erl
  12. +224 −74 src/yaws_ctl.erl
  13. +50 −49 src/yaws_log.erl
  14. +91 −115 src/yaws_server.erl
View
@@ -29,7 +29,8 @@
include_dir = [],
yaws, %% server string
username, %% maybe run as a different user than root
- uid %% unix uid of user that started yaws
+ uid, %% unix uid of user that started yaws
+ id = "default" %% string identifying this instance of yaws
}).
View
@@ -12,6 +12,7 @@
clisock, %% the socket leading to the peer client
headers, %% headers
req, %% request
+ sc, %% The sconf for this request
clidata, %% The client data (as a binary in POST requests)
server_path, %% The normalized server path
querydata, %% Was the URL on the form of ...?query (GET reqs)
View
@@ -12,6 +12,9 @@ in interactive mode where it is possible to directly interact
with the webserver. Yaws is particularly good at generating
dynamic content. See the user docs for more information on that topic.
+.SH DEAMON/SERVER options
+
+
.TP
\fB\-i\fR
Interactive mode. This will start yaws in interactive mode with an erlang
@@ -28,7 +31,9 @@ switch to be present.
.TP
\fB\-d\fR
Debug mode. This will produce some auxilliary error output for some
-error conditions. The interactive option \fI-i\rR implies debug mode.
+error conditions. It will also start the otp sasl lib for additional
+error printouts.
+
.TP
\fB\-c file\fR
Use a different configuration file than the default. The default configuration file
@@ -39,10 +44,16 @@ $HOME/yaws.conf, then in ./yaws.conf and finally in /etc/yaws.conf
\fB\-r module\fR
Tells yaws to call \fImodule:start/0\fR at startup. This makes it possible
to startup user specific applications together with yaws.
+
+.TP
+\fB\-pa path\fR
+Add path to the yaws system search path
+
.TP
\fB\-t\fR
Traffic trace mode. All traffic will be written to a trace file called trace.traffic
in the log directory.
+
.TP
\fB\-T\fR
HTTP trace mode. All HTTP messages will be written to a trace file called trace.http
@@ -60,21 +71,47 @@ Start Mnesia in directory <dir>
\fB\-sname xxx\fR
Start yaws as a distributed erlang node with name <xxx>
+
+
+.SH CONTROL OPTIONS
+.PP
+The following list of options are are used to control the daemon
+from the "outside" while it is running.
+
.TP
-\fB\-h\fR
-HUP the daemon. This forces the daemon to reread the configuration file. It also makes
-the daemon empty all its internal content caches. Hence when updating the doc root,
+\fB\-I id\fR
+Only useful with the control commands, -h, -s and -S, -j and -load. It interacts
+with the yaws server named "id" (as specified in the conf file for
+that yaws server)
+
+
+.TP
+\fB\-h [-I id]\fR
+HUP the daemon. This forces the daemon to reread the configuration file.
+It also makes
+the daemon empty all its internal content caches.
+Hence when updating the doc root,
HUPing the daemon is the fastest way to see the content updates.
.TP
-\fB\-s\fR
-Stop the daemon.
+\fB\-s [-I id]\fR
+Stop the daemon (called id)
.TP
-\fB-S\fR
+\fB-S [-I id]\fR
Query a running yaws daemon for its status, and print it.
.TP
-\fB-load Modules\fR
+\fB-load Modules [-I id]\fR
Try to (re)load erlang modules into a running daemon. This is useful
after modifying appmods or modules used by scripts.
+
+.TP
+\fB-j [-I id] http | traffic | off\fR
+Control the trace capabilities of a running yaws daemon. If the
+http or traffic option is given, the daemon will write a log
+for debug purposes into the logdir.
+
+
+.SH MISC OPTIONS
+
.TP
\fB-check YawsFile [IncDirs]\fR
Test compile a `.yaws' file.
View
@@ -40,6 +40,25 @@ The default value for logdir is "."
\fB ebin_dir = Directory\fR
This directive adds Directory to the erlang search path. It is possible to
have several of these command in the configuration file.
+
+
+.TP
+\fB id = String\fR
+It is possible run multiple yaws servers on the same machine. We use the
+id of a yaws server to control it using the different ctl commands such
+as:
+.nf
+
+# /usr/local/bin/yaws -I foobar -s
+
+.fi
+To stop the Yaws server with id "foobar". Only the user that started
+the server called foobar is allowd to stop and control it. This is achieved
+through file permissions on the control file which will reside in
+"/tmp/yaws/foobar/ctl"
+
+There can never be two yaws servers on the same machine with identical ids.
+
.TP
\fB include_dir = Directory\fR
This directive adds Directory to the path of directories where the erlang
View
@@ -322,6 +322,11 @@ Url-encodes a string. All URLs in HTML documents must be URL encoded.
Returns a list of reformated header values from a #header{}
record. The return list is suitable for retransmit.
+.TP
+\fBrequest_url(ARG)\fR
+Return the url as requested by the client. Return value
+is a #url{} record as defined in yaws_api.hrl
+
.TP
\fBparse_url(Str)\fR
View
@@ -20,6 +20,7 @@ clean:
rm -f ../bin/yaws
install: all .foo
+ -rm -rf /tmp/yaws 2> /dev/null
.foo:
sh -x ./Install $(PREFIX) $(INSTALLPREFIX) "$(ERL)" "$(WERL)" $(ETCDIR)
View
@@ -16,35 +16,47 @@ esac
ENV_PGM=`which env`
+
help()
{
- echo "usage: server modes ... "
- echo " yaws -i -- interactive (no daemon) mode"
+ echo "usage: "
+ echo ""
+ echo
+ echo " yaws -i -- interactive (no daemon) mode"
echo " yaws -w -- cygwin interactive (werl) "
- echo " yaws -D -- daemon mode"
- echo " yaws -d -- debug mode"
- echo " yaws -c file -- set config file"
- echo " yaws -r mod -- call mod:start/0 at startup"
- echo " yaws -t -- trace all traffic"
- echo " yaws -T -- trace http traffic"
- echo " yaws -x -- trace output to stdout"
- echo " yaws -v -- print version"
- echo " yaws -M dir -- start Mnesia in dir"
- echo " yaws -sname xxx -- start with sname xxx"
- echo ""
- echo " yaws -heart -- auto restart yaws if it crashes"
- echo " (requires the -D switch)"
- echo ""
- echo ""
- echo "ctl functions ... "
- echo " yaws -h -- hup the daemon "
- echo " yaws -s -- stop the daemon "
- echo " yaws -S -- query the daemon status "
- echo " yaws -load Modules -- load modules "
- echo " yaws -check YawsFile [IncDirs] -- test compile File "
- exit 1
+ echo " yaws -D -- daemon mode"
+
+ echo ""
+
+ echo ""
+ echo " Auxilliary flags for the daemon: "
+ echo " -I Id -- Set system id"
+ echo " -d -- debug mode "
+ echo " -c File -- set config file"
+ echo " -r mod -- call mod:start/0 at startup"
+ echo " -t -- trace all traffic"
+ echo " -T -- trace http traffic"
+ echo " -x -- trace output to stdout"
+ echo " -v -- print version"
+ echo " -pa path -- add path"
+ echo " -M dir -- start Mnesia in dir"
+ echo " -sname xxx -- start with sname xxx"
+ echo " -r mod -- call mod:start/0 at startup"
+ echo " -heart -- auto restart yaws if it crashes"
+
+ echo ""
+
+ echo "ctl functions ... "
+ echo " yaws -h [-I id] -- hup the daemon "
+ echo " yaws -s [-I id] -- stop the daemon "
+ echo " yaws -S [-I id] -- query the daemon status "
+ echo " yaws -load Modules -- load modules "
+ echo " yaws -j traffic|http -- toggle trace of running daemon"
+ echo " yaws -check YawsFile [IncDirs] -- test compile File "
+ exit 1
}
-
+
+
debug="";
daemon="";
@@ -56,6 +68,7 @@ sname="";
heart="";
xpath="";
mnesia="";
+id="default";
while [ $# -gt 0 ]
do
@@ -79,6 +92,9 @@ do
trace=" -yaws trace traffic ";;
-T)
trace=" -yaws trace http ";;
+ -I)
+ id=$1
+ shift;;
-x)
traceoutput=" -yaws traceoutput ";;
-M)
@@ -94,17 +110,17 @@ do
runmod=" -runmod $1 "
shift;;
-h)
- exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl hup;
- exit 0;;
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl hup";;
-s)
- exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stop;
- exit 0;;
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stop";;
-S)
- exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status;
- exit 0;;
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status";;
-load)
- exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load $*;
+ $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load ${id} $*
exit 0;;
+ -j)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl trace $1"
+ shift;;
-v)
exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws printversion;
exit 0;;
@@ -129,6 +145,13 @@ do
esac
done
+
+if [ ! -z "${ex}" ]; then
+ exec ${ex} ${id}
+ exit 0
+fi
+
+
trace="${trace} ${traceoutput}"
[ -z "$daemon" ] && [ -z "$interactive" ] && help
@@ -137,10 +160,10 @@ if [ -z "$heart" ] || [ -z "$daemon" ]; then
HEART_COMMAND="";
else
## ............................this line
- export HEART_COMMAND="${ENV_PGM} HEART=true \"$erl\" ${daemon} ${heart} -pa ${yawsdir}${delim}ebin ${sname} ${debug} -s yaws $trace $conf $runmod $mnesia";
+ export HEART_COMMAND="${ENV_PGM} HEART=true \"$erl\" ${daemon} ${heart} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${debug} -s yaws $trace $conf $runmod $mnesia";
fi
## keep this line in sync with ....^
-exec "$erl" ${daemon} ${heart} -pa ${yawsdir}${delim}ebin ${sname} ${debug} -s yaws $trace $conf $runmod $mnesia
+exec "$erl" ${daemon} ${heart} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${debug} -s yaws $trace $conf $runmod $mnesia
Oops, something went wrong.

0 comments on commit dc00e52

Please sign in to comment.