Permalink
Browse files

--running-config flag to query a running yaws for its config

  • Loading branch information...
1 parent 035303b commit 713e35b4c90519c9af37fde2ac45878f15b4e3e0 @klacke committed Oct 5, 2010
Showing with 31 additions and 2 deletions.
  1. +6 −0 man/yaws.1
  2. +2 −0 scripts/yaws.template
  3. +23 −2 src/yaws_ctl.erl
View
@@ -173,6 +173,12 @@ Query a running yaws daemon for its status, and print it.
\fB--stats [--id id]\fR
Query a running yaws daemon for its statistics, and print it.
.TP
+\fB--running-config [--id id]\fR
+Query a running yaws daemon for its current configuration, and print it.
+This can be useful when attempting to figure out how to set config
+in embedded mode. Configure yaws to you liking in non-embedded mode, run
+this command and use the output to populate the embedded mode records.
+.TP
\fB--load Modules [--id id]\fR
Try to (re)load erlang modules into a running daemon. This is useful
after modifying appmods or modules used by scripts.
View
@@ -213,6 +213,8 @@ while [ $# -gt 0 ]
ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl status";;
--stats)
ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl stats";;
+ --running-config)
+ ex="$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl running_config";;
-load|--load)
loadid=${id:-default}
$erl -noshell -pa ${yawsdir}${delim}ebin -s yaws_ctl load $* $loadid
View
@@ -18,7 +18,7 @@
-export([start/2, actl_trace/1]).
-export([ls/1,hup/1,stop/1,status/1,load/1,
- check/1,trace/1, debug_dump/1, stats/1]).
+ check/1,trace/1, debug_dump/1, stats/1, running_config/1]).
%% internal
-export([run/1, aloop/3, handle_a/3]).
@@ -179,6 +179,9 @@ handle_a(A, GC, Key) ->
{stats, Key} ->
a_stats(A),
gen_tcp:close(A);
+ {running_config, Key} ->
+ a_running_config(A),
+ gen_tcp:close(A);
{Other, Key} ->
gen_tcp:send(A, io_lib:format("Other: ~p~n", [Other])),
gen_tcp:close(A);
@@ -286,6 +289,23 @@ format_ip(IP) ->
[A, B, C, D, E, F, G, H])
end.
+
+a_running_config(Sock) ->
+ gen_tcp:send(Sock, a_running_config()).
+a_running_config() ->
+ {ok, GC, Groups} = yaws_server:getconf(),
+ GcStr = ?format_record(GC, gconf),
+ L = lists:map(fun(Group) ->
+ ["** GROUP ** \n",
+ lists:map(
+ fun(SC) ->
+ ?format_record(SC, sconf)
+ end,
+ Group)
+ ]
+ end, Groups),
+ ["** GLOBAL CONF ** \n", GcStr, L].
+
a_stats(Sock) ->
gen_tcp:send(Sock, a_stats()).
a_stats() ->
@@ -544,4 +564,5 @@ debug_dump([SID]) ->
stats([SID]) ->
actl(SID, stats).
-
+running_config([SID]) ->
+ actl(SID, running_config).

0 comments on commit 713e35b

Please sign in to comment.