Permalink
Browse files

run_erl to_erl support patch from Mats Cronquist

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@967 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent 8c2b2ad commit 28972a3cd8695df9c12e85d72e995c1835f29090 @klacke committed May 30, 2006
Showing with 175 additions and 135 deletions.
  1. +2 −2 doc/Makefile
  2. +1 −0 include.mk.in
  3. +4 −0 scripts/Install
  4. +163 −131 scripts/yaws.template
  5. +2 −1 src/yaws_config.erl
  6. +3 −1 src/yaws_ctl.erl
View
@@ -29,6 +29,6 @@ clean:
-rm *~ *.ps *.dvi *.log *.aux *.pdf *.toc *.beam 2> /dev/null
install:
- -install -d $(INSTALLPREFIX)/share/doc/yaws-$(YAWS_VSN)
- -cp yaws.pdf $(INSTALLPREFIX)/share/doc/yaws-$(YAWS_VSN)
+ -install -d $(DESTDIR)/$(PREFIX)/share/doc/yaws-$(YAWS_VSN)
+ -cp yaws.pdf $(DESTDIR)/$(PREFIX)/share/doc/yaws-$(YAWS_VSN)
View
@@ -2,6 +2,7 @@
PREFIX = @prefix@
+prefix = ${PREFIX}
ETCDIR = @sysconfdir@
VARDIR = @localstatedir@
View
@@ -8,6 +8,7 @@ erl=$3
werl=$4
etcdir=$5
vardir=$6
+bindir=`dirname $erl` ; bindir=`dirname $bindir`/lib/erlang/bin
. ../vsn.mk
y=yaws-${YAWS_VSN}
@@ -19,7 +20,10 @@ install -d ${destdir}/${prefix}/bin
cat yaws.template | \
./Subst %yawsdir% ${prefix}/lib/yaws | \
+ ./Subst %vardir% ${vardir} | \
./Subst %erl% "${erl}" | \
+ ./Subst %run_erl% "${bindir}/run_erl" | \
+ ./Subst %to_erl% "${bindir}/to_erl" | \
./Subst %werl% "${werl}" > ${destdir}/${prefix}/bin/yaws
chmod +x ${destdir}/${prefix}/bin/yaws
View
@@ -1,8 +1,11 @@
#!/bin/sh
-
yawsdir="%yawsdir%"
+vardir="%vardir%"
erl="%erl%"
+run_erl="%run_erl%"
+to_erl="%to_erl%"
+
case `uname` in
CYGWIN*)
yawsdir=`cygpath --windows $yawsdir`
@@ -19,44 +22,46 @@ ENV_PGM=`which env`
help()
{
- echo "usage: "
- echo ""
- echo
- echo " yaws -i | --interactive -- interactive (no daemon) mode"
- echo " yaws -w | --winteractive -- cygwin interactive (werl) "
- echo " yaws --daemon -- daemon mode"
-
- echo ""
-
- echo ""
- echo " Auxilliary flags for the daemon: "
- echo " --id Id -- Set system id"
- echo " --debug -- debug mode "
- echo " --conf File -- set config file"
- echo " --tracetraf -- trace traffic"
- echo " --tracehttp -- trace http traffic"
- echo " --traceout -- trace output to stdout"
- echo " --version -- print version"
- echo " --pa path -- add load path"
- echo " --mnesiadir dir -- start Mnesia in dir"
- echo " --proto_dist Mod -- use Mod for distrib"
- echo " --sname xxx -- start with sname xxx"
- echo " --name xxx -- start with name xxx"
- echo " --runmod mod -- call mod:start/0 at startup"
- echo " --heart -- auto restart yaws if it crashes"
- echo " --erlarg X -- pass argument X to $erl"
-
- echo ""
-
- echo "ctl functions ... "
- echo " yaws --hup [--id ID] -- hup the daemon, reload conf
- echo " yaws --stops [--id ID] -- stop the daemon "
- echo " yaws --status [--id ID] -- query the daemon status "
- echo " yaws --load Modules -- load modules "
- echo " yaws --ls -- list Yaws nodes and their status
- echo " yaws --ctltrace traffic|http -- toggle trace of running daemon"
- echo " yaws --check YawsFile [IncDirs] -- test compile File "
- exit 1
+ echo "usage: "
+ echo ""
+ echo
+ echo " yaws -i | --interactive -- interactive (no daemon) mode"
+ echo " yaws -w | --winteractive -- cygwin interactive (werl) "
+ echo " yaws --daemon -- daemon mode"
+
+ echo ""
+
+ echo ""
+ echo " Auxilliary flags for the daemon: "
+ echo " --id Id -- Set system id"
+ echo " --debug -- debug mode "
+ echo " --conf File -- set config file"
+ echo " --tracetraf -- trace traffic"
+ echo " --tracehttp -- trace http traffic"
+ echo " --traceout -- trace output to stdout"
+ echo " --version -- print version"
+ echo " --pa path -- add load path"
+ echo " --mnesiadir dir -- start Mnesia in dir"
+ echo " --proto_dist Mod -- use Mod for distrib"
+ echo " --sname xxx -- start with sname xxx"
+ echo " --name xxx -- start with name xxx"
+ echo " --runmod mod -- call mod:start/0 at startup"
+ echo " --heart -- auto restart yaws if it crashes"
+ echo " --erlarg X -- pass argument X to $erl"
+ echo " --run_erl X -- use run_erl with pipe-id X"
+ echo " --to_erl X -- connect to pipe-id X"
+
+ echo ""
+
+ echo "ctl functions ... "
+ echo " yaws --hup [--id ID] -- hup the daemon, reload conf"
+ echo " yaws --stops [--id ID] -- stop the daemon "
+ echo " yaws --status [--id ID] -- query the daemon status "
+ echo " yaws --load Modules -- load modules "
+ echo " yaws --ls -- list Yaws nodes and their status"
+ echo " yaws --ctltrace traffic|http -- toggle trace of running daemon"
+ echo " yaws --check YawsFile [IncDirs] -- test compile File "
+ exit 1
}
@@ -76,91 +81,103 @@ pdist=""
erlarg=""
while [ $# -gt 0 ]
-do
- arg=$1
- shift;
- case $arg in
- -i|--interactive)
- interactive="true";
- debug=" -yaws debug ";
- daemon="";;
- -w|--winteractive)
- interactive="true";
- debug=" -yaws debug ";
- daemon="";
- erl=$werl;;
- -D|--daemon)
- daemon=" -detached ";;
- -d|--debug)
- debug=" -boot start_sasl -yaws debug ";;
- -t|--tracetraf)
- trace=" -yaws trace traffic ";;
- -T|--tracehttp)
- trace=" -yaws trace http ";;
- -I|--id)
- id=$1
- shift;;
- -x|--traceout)
- traceoutput=" -yaws traceoutput ";;
- --trace)
- traceoutput=" -yaws traceoutput ";
- trace=" -yaws trace traffic ";;
- -M|--mnesiadir)
- mnesia=" -mnesia dir '"$1"' -run mnesia start"
- shift;;
- -c|--conf)
- conf=" -conf $1 "
- shift;;
- -pa|--pa)
- xpath=" ${xpath} -pa $1 "
- shift;;
- -r|--runmod)
- runmod=" -runmod $1 "
- shift;;
- -h|--hup)
- ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl hup";;
- -s|--stop)
- ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stop";;
- -ls|--ls)
- ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl ls";;
- -S|--status)
- ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status";;
- -load|--load)
- $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load ${id} $*
- exit 0;;
- -j|--ctltrace)
- ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl trace $1"
- shift;;
- -v|--version)
- exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws printversion;
- exit 0;;
- --sname|-sname)
- sname=" -sname $1 "
- shift;;
- -name|--name)
- sname=" -name $1 "
- shift;;
- -heart|--heart)
- heart=" -heart ";;
- -proto_dist|--proto_dist)
- pdist=" -proto_dist $1 "
- shift;;
- -erlarg|--erlarg)
- 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} $*`
- if [ "$out" = "ok" ]; then
- echo "$1" ok
- exit 0
- fi
- echo $out
- exit 1;;
- *)
- help
- esac
+ do
+ arg=$1
+ shift;
+ case $arg in
+ -i|--interactive)
+ interactive="true";
+ debug=" -yaws debug ";
+ daemon="";;
+ -w|--winteractive)
+ interactive="true";
+ debug=" -yaws debug ";
+ daemon="";
+ erl=$werl;;
+ -D|--daemon)
+ daemon=" -detached ";;
+ -d|--debug)
+ debug=" -boot start_sasl -yaws debug ";;
+ -t|--tracetraf)
+ trace=" -yaws trace traffic ";;
+ -T|--tracehttp)
+ trace=" -yaws trace http ";;
+ -I|--id)
+ id=$1
+ shift;;
+ -x|--traceout)
+ traceoutput=" -yaws traceoutput ";;
+ --trace)
+ traceoutput=" -yaws traceoutput ";
+ trace=" -yaws trace traffic ";;
+ -M|--mnesiadir)
+ mnesia=" -mnesia dir '"$1"' -run mnesia start"
+ shift;;
+ -c|--conf)
+ conf=" -conf $1 "
+ shift;;
+ -pa|--pa)
+ xpath=" ${xpath} -pa $1 "
+ shift;;
+ -r|--runmod)
+ runmod=" -runmod $1 "
+ shift;;
+ -h|--hup)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl hup";;
+ -s|--stop)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stop";;
+ -ls|--ls)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl ls";;
+ -S|--status)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status";;
+ -load|--load)
+ $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load ${id} $*
+ exit 0;;
+ -j|--ctltrace)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl trace $1"
+ shift;;
+ -v|--version)
+ exec $erl -noshell -pa ${yawsdir}${delim}ebin -s yaws printversion;
+ exit 0;;
+ --sname|-sname)
+ sname=" -sname $1 "
+ shift;;
+ -name|--name)
+ sname=" -name $1 "
+ shift;;
+ -heart|--heart)
+ heart=" -heart ";;
+ -proto_dist|--proto_dist)
+ pdist=" -proto_dist $1 "
+ shift;;
+ -erlarg|--erlarg)
+ 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} $*`
+ if [ "$out" = "ok" ]; then
+ echo "$1" ok
+ exit 0
+ fi
+ echo $out
+ exit 1;;
+ --to_erl)
+ TO_ERL=yes
+ PIPE_DIR="${vardir}/run/yaws/pipe/$1"
+ shift;;
+ --run_erl)
+ RUN_ERL=yes
+ RUN_ERL_LOG_GENERATIONS=8 ; export RUN_ERL_LOG_GENERATIONS
+ RUN_ERL_LOG_MAXSIZE=1000000 ; export RUN_ERL_LOG_MAXSIZE
+ daemon=""
+ PIPE_DIR="${vardir}/run/yaws/pipe/$1"
+ LOG_DIR="${vardir}/log/yaws/erlang-log/$1"
+ shift;;
+ *)
+ help
+ esac
done
@@ -169,22 +186,37 @@ if [ ! -z "${ex}" ]; then
exit 0
fi
+if [ -n "$TO_ERL" ]; then
+ $to_erl $PIPE_DIR/
+ exit 0
+fi
+
+if [ -n "$RUN_ERL" ]; then
+ if [ ! -d $LOG_DIR ]; then
+ mkdir -p $LOG_DIR
+ fi
+ if [ ! -d $PIPE_DIR ]; then
+ mkdir -p $PIPE_DIR
+ fi
+ RUN_ERL="$run_erl -daemon $PIPE_DIR/ $LOG_DIR"
+else
+ RUN_ERL="eval"
+fi
+
if [ ! -z "${id}" ]; then
id="-yaws id ${id}"
fi
trace="${trace} ${traceoutput}"
-[ -z "$daemon" ] && [ -z "$interactive" ] && help
+[ "$run_erl" = "eval" ] && [ -z "$daemon" ] && [ -z "$interactive" ] && help
+
+XEC="${daemon} ${heart} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${pdist} ${erlarg} ${debug} -run yaws ${trace} ${conf} ${runmod} ${mnesia} ${id}"
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 ${xpath} ${sname} ${pdist} ${erlarg} ${debug} -s yaws ${trace} ${conf} ${runmod} ${mnesia} ${id}";
+ export HEART_COMMAND="${ENV_PGM} HEART=true \"$erl\" $XEC";
fi
-## keep this line in sync with ....^
-exec "$erl" ${daemon} ${heart} -pa ${yawsdir}${delim}ebin ${xpath} ${sname} ${pdist} ${erlarg} ${debug} -s yaws ${trace} ${conf} ${runmod} ${mnesia} ${id}
-
-
+${RUN_ERL} "exec $erl $XEC"
View
@@ -499,7 +499,8 @@ fload(FD, globals, GC, C, Cs, Lno, Chars) ->
false ->
{error, ?F("Expect true|false at line ~w", [Lno])}
end;
- ["id", '=', String] when GC#gconf.id == undefined ->
+ ["id", '=', String] when GC#gconf.id == undefined;
+ GC#gconf.id == default ->
fload(FD, globals, GC#gconf{id=String},C, Cs, Lno+1, Next);
["id", '=', String] ->
error_logger:format("Ignoring 'id = ~p' setting at line ~p~n", [String,Lno]),
View
@@ -124,7 +124,9 @@ w_ctl_file(Sid, Port) ->
ctl_file(Sid) ->
- filename:join([yaws_generated:ctldir(), "ctl-" ++ yaws:to_list(Sid)]).
+ FN = filename:join([yaws_generated:ctldir(), "ctl-" ++ yaws:to_list(Sid)]),
+ filelib:ensure_dir(FN),
+ FN.
aloop(L, GC) ->

0 comments on commit 28972a3

Please sign in to comment.