Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added command `-load' to yaws script.

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@457 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
commit caa1a726bef22ead780ca1eef239b0af2c680575 1 parent f08b885
@carsten3347 carsten3347 authored
Showing with 44 additions and 4 deletions.
  1. +7 −3 scripts/yaws.ss
  2. +37 −1 src/yaws_ctl.erl
View
10 scripts/yaws.ss
@@ -25,9 +25,10 @@ help()
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 -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
}
@@ -74,6 +75,9 @@ do
-S)
exec $erl -noshell -pa ${yawsdir}/ebin -s yaws_ctl status;
exit 0;;
+ -load)
+ exec $erl -noshell -pa ${yawsdir}/ebin -s yaws_ctl load $*;
+ exit 0;;
-v)
exec $erl -noshell -pa ${yawsdir}/ebin -s yaws printversion;
exit 0;;
View
38 src/yaws_ctl.erl
@@ -58,7 +58,7 @@ aloop(L) ->
_Err ->
ignore
end,
- aloop(L).
+ ?MODULE:aloop(L).
handle_a(A) ->
case gen_tcp:recv(A, 0) of
@@ -73,6 +73,9 @@ handle_a(A) ->
status ->
a_status(A),
gen_tcp:close(A);
+ {load, Mods} ->
+ a_load(A, Mods),
+ gen_tcp:close(A);
Other ->
gen_tcp:send(A, io_lib:format("Other: ~p~n", [Other])),
gen_tcp:close(A)
@@ -112,6 +115,36 @@ a_status(Sock) ->
%% Now lets' figure out the status of loaded modules
ok.
+a_load(A, Mods) ->
+ case purge(Mods) of
+ ok ->
+ gen_tcp:send(A, f("~p~n", [loadm(Mods)]));
+ Err ->
+ gen_tcp:send(A, f("~p~n", [Err]))
+ end.
+
+loadm([]) ->
+ [];
+loadm([M|Ms]) ->
+ [code:load_file(M)|loadm(Ms)].
+
+purge(Ms) ->
+ case purge(Ms, []) of
+ [] -> ok;
+ L -> {cannot_purge, L}
+ end.
+
+purge([], Ack) ->
+ Ack;
+purge([M|Ms], Ack) ->
+ case code:soft_purge(M) of
+ true ->
+ purge(Ms, Ack);
+ false ->
+ purge(Ms, [M|Ack])
+ end.
+
+
actl(Term, Uid) ->
CtlFile = ctl_file(Uid),
@@ -162,6 +195,9 @@ stop() ->
status() ->
actl(status, uid()).
+load(Modules) ->
+ actl({load, Modules}, uid()).
+
check([File| IncludeDirs]) ->
GC = yaws_config:make_default_gconf(false),
GC2 = GC#gconf{include_dir = lists:map(fun(X) -> atom_to_list(X) end,
Please sign in to comment.
Something went wrong with that request. Please try again.