Skip to content
This repository
Newer
Older
100644 547 lines (468 sloc) 16.559 kb
38fb85e6 »
2002-04-30 ""
1 %%%----------------------------------------------------------------------
2 %%% File : yaws_ctl.erl
3 %%% Author : Claes Wikstrom <klacke@bluetail.com>
4 %%% Purpose :
5 %%% Created : 29 Apr 2002 by Claes Wikstrom <klacke@bluetail.com>
6 %%%----------------------------------------------------------------------
7
8
9 %% some code to remoteley control a running yaws server
10
11 -module(yaws_ctl).
12 -author('klacke@bluetail.com').
13
14 -include_lib("kernel/include/file.hrl").
6cf3eceb »
2005-11-20 ""
15 -include("../include/yaws.hrl").
16 -include("../include/yaws_api.hrl").
28e4c738 »
2003-09-08 first attempt to run properly under cygwin
17 -include("yaws_debug.hrl").
2f51c682 »
2002-11-20 -check arg
18
9a74e5aa »
2008-05-12 Major general code cleanup, finally got rid of all the export_all sta…
19 -export([start/2, actl_trace/1]).
20 -export([ls/1,hup/1,stop/1,status/1,load/1,
dbaab8bd »
2009-06-12 Stats command
21 check/1,trace/1, debug_dump/1, stats/1]).
9a74e5aa »
2008-05-12 Major general code cleanup, finally got rid of all the export_all sta…
22 %% internal
aa815f2d »
2008-05-17 added a set of infinity to several gen_server:calls
23 -export([run/1, aloop/3, handle_a/3]).
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
24
25
26 %% assumes the appropriate file structures
27 %% are already created with the right perms
28
6dc4cca7 »
2004-05-25 ""
29 start(_GC, FirstTime) when FirstTime == false ->
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
30 ok;
31 start(GC, true) ->
d07115cd »
2008-03-10 Several cleanups due to dialyzer, also moved the control file into us…
32 proc_lib:start_link(?MODULE, run, [GC]).
28e4c738 »
2003-09-08 first attempt to run properly under cygwin
33
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
34
35 run(GC) ->
36 %% First check if there is already a Yaws system running
37 %% with the same sid.
38 case connect(GC#gconf.id) of
0be3c7e8 »
2008-02-14 untabified all of yaws
39 {ok, Sock, _Key} ->
ddf3bee5 »
2009-01-08 preparing for 1.78
40 %% Not good,
0be3c7e8 »
2008-02-14 untabified all of yaws
41 gen_tcp:close(Sock),
42 e("There is already a yaws system running with the same ~n"
d07115cd »
2008-03-10 Several cleanups due to dialyzer, also moved the control file into us…
43 " id <~p> on this computer and this user, ~n"
0be3c7e8 »
2008-02-14 untabified all of yaws
44 " set another id in the yaws conf file ~n",
45 [GC#gconf.id]);
fb694a00 »
2008-05-27 eaccess typos in confd_ctl.erl - Sergei Golovan
46 {error, eacces} ->
0be3c7e8 »
2008-02-14 untabified all of yaws
47 %% We're not allowed to open the ctl file
d07115cd »
2008-03-10 Several cleanups due to dialyzer, also moved the control file into us…
48 e("Error reading ~s, you don't have access rights to read it",
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
49 [yaws:ctl_file(GC#gconf.id)]);
0be3c7e8 »
2008-02-14 untabified all of yaws
50 {error, _} ->
51 %% Fine, this should be the case
52 run_listen(GC)
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
53 end.
54
3c751604 »
2008-05-17 better crypto on user/id key
55 rand() ->
78713383 »
2009-02-11 win32 work
56 case os:type() of
57 {win32, _} ->
58 {A1, A2, A3}=now(),
3c751604 »
2008-05-17 better crypto on user/id key
59 random:seed(A1, A2, A3),
78713383 »
2009-02-11 win32 work
60 random:uniform(1 bsl 64);
61 _ ->
62 try
63 crypto:start(),
64 crypto:rand_uniform(0, 1 bsl 64)
65 catch
9ab391e5 »
2009-07-03 warn when crypto app is not there
66 _:_ ->
67 error_logger:warning_msg("Running without crypto app\n"),
78713383 »
2009-02-11 win32 work
68 {A1, A2, A3}=now(),
69 random:seed(A1, A2, A3),
70 random:uniform(1 bsl 64)
71 end
3c751604 »
2008-05-17 better crypto on user/id key
72 end.
73
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
74
78713383 »
2009-02-11 win32 work
75
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
76 ctl_args() ->
0be3c7e8 »
2008-02-14 untabified all of yaws
77 [{packet, 2},
78 {active, false},
79 binary,
80 {ip, {127,0,0,1}},
81 {reuseaddr, true}].
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
82
83 run_listen(GC) ->
84 case gen_tcp:listen(0, ctl_args()) of
0be3c7e8 »
2008-02-14 untabified all of yaws
85 {ok, L} ->
86 case inet:sockname(L) of
87 {ok, {_, Port}} ->
3c751604 »
2008-05-17 better crypto on user/id key
88 Key = rand(),
0be3c7e8 »
2008-02-14 untabified all of yaws
89 case w_ctl_file(GC#gconf.id, Port, Key) of
90 ok ->
91 proc_lib:init_ack(ok),
92 aloop(L, GC, Key);
93 error ->
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
94 e(
0be3c7e8 »
2008-02-14 untabified all of yaws
95 "Failed to create/manipulate the ctlfile ~n"
96 "called ~s~n"
97 "Either problems with permissions or "
98 " earlier runs of yaws ~nwith the same id "
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
99 " <~p> as this, check dir for perms~n",
100 [yaws:ctl_file(GC#gconf.id), GC#gconf.id])
0be3c7e8 »
2008-02-14 untabified all of yaws
101 end;
102 Err ->
103 e("Cannot get sockname for ctlsock: ~p",[Err] )
104 end;
105 Err ->
106 e("Cannot listen on ctl socket, fatal: ~p", [Err])
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
107 end.
108
0c9da974 »
2002-11-27 added ability to run as different user than root
109
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
110 e(Fmt, Args) ->
111 proc_lib:init_ack({error, io_lib:format(Fmt, Args)}),
112 exit(normal).
113
114
115
116 %% write the control file, set perms of the file
117 %% so that only this user can read the file
118 %% That way we're making sure different users
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
119 %% cannot manipulate each others webservers
f4e3e442 »
2006-07-06 patch by Sergei Golovan which fixed a CGI bug and made yaws_ctl safe
120 w_ctl_file(Sid, Port, Key) ->
121 case catch
0be3c7e8 »
2008-02-14 untabified all of yaws
122 begin
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
123 F = yaws:ctl_file(Sid),
124 error_logger:info_msg("Ctlfile : ~s~n", [F]),
0be3c7e8 »
2008-02-14 untabified all of yaws
125 file:write_file(F, io_lib:format("~w.", [{Port,Key}])),
126 {ok, FI} = file:read_file_info(F),
127 ok = file:write_file_info(F, FI#file_info{mode = 8#00600})
128 end of
129 {'EXIT', _} ->
130 error;
131 _ ->
132 ok
133 end.
38fb85e6 »
2002-04-30 ""
134
135
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
136
f4e3e442 »
2006-07-06 patch by Sergei Golovan which fixed a CGI bug and made yaws_ctl safe
137 aloop(L, GC, Key) ->
38fb85e6 »
2002-04-30 ""
138 case gen_tcp:accept(L) of
0be3c7e8 »
2008-02-14 untabified all of yaws
139 {ok, A} ->
aa815f2d »
2008-05-17 added a set of infinity to several gen_server:calls
140 proc_lib:spawn (?MODULE, handle_a, [A, GC, Key]);
0be3c7e8 »
2008-02-14 untabified all of yaws
141 Err ->
142 error_logger:format("yaws_ctl failed to accept: ~p~n",
143 [Err]),
144 timer:sleep(2000),
145 ignore
38fb85e6 »
2002-04-30 ""
146 end,
f4e3e442 »
2006-07-06 patch by Sergei Golovan which fixed a CGI bug and made yaws_ctl safe
147 ?MODULE:aloop(L, GC, Key).
38fb85e6 »
2002-04-30 ""
148
f4e3e442 »
2006-07-06 patch by Sergei Golovan which fixed a CGI bug and made yaws_ctl safe
149 handle_a(A, GC, Key) ->
38fb85e6 »
2002-04-30 ""
150 case gen_tcp:recv(A, 0) of
0be3c7e8 »
2008-02-14 untabified all of yaws
151 {ok, Data} ->
152 case catch binary_to_term(Data) of
153 {hup, Key} ->
154 Res = yaws:dohup(A),
155 Res;
156 {stop, Key} ->
157 gen_tcp:send(A, io_lib:format(
158 "stopping yaws with id=~p\n",
159 [GC#gconf.id])),
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
160 file:delete(yaws:ctl_file(GC#gconf.id)),
0be3c7e8 »
2008-02-14 untabified all of yaws
161 init:stop();
162 {{trace, What}, Key} ->
163 Res = actl_trace(What),
164 gen_tcp:send(A, Res),
165 gen_tcp:close(A);
166 {status, Key} ->
167 a_status(A),
168 gen_tcp:close(A);
169 {{load, Mods}, Key} ->
170 a_load(A, Mods),
171 gen_tcp:close(A);
172 {id, Key} ->
173 a_id(A),
174 gen_tcp:close(A);
5207102c »
2008-05-17 Added debug dump functionality
175 {debug_dump, Key} ->
176 a_debug_dump(A),
177 gen_tcp:close(A);
dbaab8bd »
2009-06-12 Stats command
178 {stats, Key} ->
179 a_stats(A),
180 gen_tcp:close(A);
0be3c7e8 »
2008-02-14 untabified all of yaws
181 {Other, Key} ->
182 gen_tcp:send(A, io_lib:format("Other: ~p~n", [Other])),
183 gen_tcp:close(A);
184 _Other ->
185 gen_tcp:close(A)
186
187 end;
188 {error, _} ->
d07115cd »
2008-03-10 Several cleanups due to dialyzer, also moved the control file into us…
189 gen_tcp:close(A)
38fb85e6 »
2002-04-30 ""
190 end.
191
63772226 »
2002-06-16 ""
192
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
193 %% We implement this by reloading a patched config
194 actl_trace(What) ->
195 case lists:member(What, [traffic, http, off]) of
0be3c7e8 »
2008-02-14 untabified all of yaws
196 true ->
197 {ok, GC, SCs} = yaws_api:getconf(),
198 case GC#gconf.trace of
199 false when What /= off->
200 yaws_api:setconf(GC#gconf{trace = {true, What}},SCs),
201 io_lib:format(
202 "Turning on trace of ~p to file ~s~n",
203 [What,
204 filename:join([GC#gconf.logdir,
205 "trace." ++ atom_to_list(What)])]);
206 false when What == off ->
207 io_lib:format("Tracing is already turned off ~n",[]);
208 {true, _} when What == off ->
209 yaws_api:setconf(GC#gconf{trace = false},SCs),
210 "Turning trace off \n";
211 {true, What} ->
212 io_lib:format("Trace of ~p is already turned on, ose 'off' "
213 "to turn off~n", [What]);
214 {true, _Other} ->
215 yaws_api:setconf(GC#gconf{trace = {true, What}},SCs),
216 io_lib:format(
217 "Turning on trace of ~p to file ~s~n",
218 [What,
219 filename:join([GC#gconf.logdir,
220 "trace." ++ atom_to_list(What)])])
221 end;
222 false ->
223 "Need either http | traffic | off as argument\n"
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
224 end.
225
226
63772226 »
2002-06-16 ""
227
228 f(Fmt, As) ->
229 io_lib:format(Fmt, As).
230
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
231
232 a_id(Sock) ->
6ef4f855 »
2008-07-09 dialyzer reports
233 ID = gen_server:call(yaws_server, id, infinity),
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
234 gen_tcp:send(Sock, ID),
235 ok.
236
63772226 »
2002-06-16 ""
237 a_status(Sock) ->
5207102c »
2008-05-17 Added debug dump functionality
238 gen_tcp:send(Sock, a_status()).
239 a_status() ->
240 try
241 {UpTime, L} = yaws_server:stats(),
242 {Days, {Hours, Minutes, _Secs}} = UpTime,
243 H = f("~n Uptime: ~w Days, ~w Hours, ~w Minutes ~n",
244 [Days, Hours, Minutes]),
245
246 T =lists:map(
247 fun({Host,IP,Hits}) ->
248 L1= f("stats for ~p at ~p ~n",
249 [Host,IP]),
250 T = "\n"
251 "URL Number of hits\n",
252 L2=lists:map(
253 fun({Url, Hits2}) ->
254 f("~-30s ~-7w ~n",
255 [Url, Hits2])
256 end, Hits),
257 END = "\n",
258 [L1, T, L2, END]
259 end, L),
260 [H, T]
261 catch
262 _:Err ->
263 io_lib:format("Cannot get status ~p~n", [Err])
264 end.
265
266
267 a_debug_dump(Sock) ->
268 gen_tcp:send(Sock, a_status()),
269 yaws_debug:do_debug_dump(Sock).
270
63772226 »
2002-06-16 ""
271
dbaab8bd »
2009-06-12 Stats command
272 -define(IPV4_FMT, "~p.~p.~p.~p").
273 -define(IPV6_FMT, "~2.16.0b~2.16.0b:~2.16.0b~2.16.0b:~2.16.0b~2.16.0b:~2.16.0b~2.16.0b").
274
275 format_ip(IP) ->
276 case size(IP) of
277 4 ->
278 {A, B, C, D} = IP,
279 io_lib:format(?IPV4_FMT,
280 [A, B, C, D]);
281
282 8 ->
283 {A, B, C, D, E, F, G, H} = IP,
284 io_lib:format(?IPV6_FMT,
285 [A, B, C, D, E, F, G, H])
286 end.
287
288 a_stats(Sock) ->
289 gen_tcp:send(Sock, a_stats()).
290 a_stats() ->
291 {ok, _GC, Servers0} = yaws_server:getconf(),
292 Servers1 = lists:flatten(Servers0),
293 %% io:format("~p~n", [Servers1]),
294 Servers2 = parse(Servers1),
295
296 case Servers2 of
297 [] ->
298 f("No statistics available~n", []);
299
300 Servers2 ->
301 Stats = fstats(Servers2),
302 Header = f("Host IP Port Hits Sent~n", []),
303
304 Lines = lists:map(fun({Host, IP0, Port, {Hits, Sent}}) ->
305 %% we don't use inet_parse:ntoa/1
306 %% since it's not documented
307 IP = format_ip(IP0),
308 f("~s ~s ~p ~p ~p~n",
309 [Host, IP, Port, Hits, Sent])
310 end, Stats),
311 [Header, Lines]
312 end.
313
314 parse(V) ->
315 parse(V, []).
316 parse([], Acc) ->
317 Acc;
318 parse([#sconf{stats=undefined}|Tail], Acc) ->
319 parse(Tail, Acc);
320 parse([#sconf{listen=IP, port=Port, servername=Servername, stats=Stats}|Tail], Acc) ->
321 Host = {Servername, IP, Port, Stats},
322 parse(Tail, [Host|Acc]).
323
324 fstats(S) ->
325 fstats(S, []).
326 fstats([], Acc) ->
327 lists:keysort(1, Acc);
328 fstats([{IP, Port, Server, Stats}|Tail], Acc) ->
329 S = {IP, Port, Server, yaws_stats:get(Stats)},
330 fstats(Tail, [S|Acc]).
331
332
caa1a726 »
2003-07-16 Added command `-load' to yaws script.
333 a_load(A, Mods) ->
334 case purge(Mods) of
0be3c7e8 »
2008-02-14 untabified all of yaws
335 ok ->
336 gen_tcp:send(A, f("~p~n", [loadm(Mods)]));
337 Err ->
338 gen_tcp:send(A, f("~p~n", [Err]))
caa1a726 »
2003-07-16 Added command `-load' to yaws script.
339 end.
340
341 loadm([]) ->
342 [];
343 loadm([M|Ms]) ->
344 [code:load_file(M)|loadm(Ms)].
345
346 purge(Ms) ->
347 case purge(Ms, []) of
0be3c7e8 »
2008-02-14 untabified all of yaws
348 [] -> ok;
349 L -> {cannot_purge, L}
caa1a726 »
2003-07-16 Added command `-load' to yaws script.
350 end.
351
352 purge([], Ack) ->
353 Ack;
354 purge([M|Ms], Ack) ->
355 case code:soft_purge(M) of
0be3c7e8 »
2008-02-14 untabified all of yaws
356 true ->
357 purge(Ms, Ack);
358 false ->
359 purge(Ms, [M|Ack])
caa1a726 »
2003-07-16 Added command `-load' to yaws script.
360 end.
361
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
362 connect(Sid) ->
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
363 connect_file(yaws:ctl_file(Sid)).
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
364
365
366 %% The ctl file contains the port number the yaws server
f4e3e442 »
2006-07-06 patch by Sergei Golovan which fixed a CGI bug and made yaws_ctl safe
367 %% is listening at and secret key string.
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
368
369 connect_file(CtlFile) ->
f4e3e442 »
2006-07-06 patch by Sergei Golovan which fixed a CGI bug and made yaws_ctl safe
370 case file:consult(CtlFile) of
0be3c7e8 »
2008-02-14 untabified all of yaws
371 {ok, [{Port, Key}]} ->
372 case gen_tcp:connect({127,0,0,1}, Port,
373 [{active, false},
374 {reuseaddr, true},
375 binary,
376 {packet, 2}], 2000) of
377 {ok, Socket} ->
4cf79779 »
2009-02-16 When yaws_ctl checks the CTL file to see if any current instance
378 case inet:port(Socket) of
379 Port ->
380 {error, erefused};
381 _ ->
382 {ok, Socket, Key}
383 end;
0be3c7e8 »
2008-02-14 untabified all of yaws
384 Err ->
385 Err
386 end;
387 Err ->
388 Err
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
389 end.
390
391
392
393 actl(SID, Term) ->
394 case connect(SID) of
fb694a00 »
2008-05-27 eaccess typos in confd_ctl.erl - Sergei Golovan
395 {error, eacces} ->
0be3c7e8 »
2008-02-14 untabified all of yaws
396 io:format("Another user is using the yaws sid <~p>, ~n"
397 "You are not allowd to read the file <~s>, ~n"
398 "specify by <-I id> which yaws system you want "
399 " to control~n",
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
400 [SID, yaws:ctl_file(SID)]),
401 timer:sleep(10),
402 erlang:halt(1);
0be3c7e8 »
2008-02-14 untabified all of yaws
403 {error, econnrefused} ->
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
404 io:format("No yaws system responds~n",[]),
405 timer:sleep(10),
406 erlang:halt(2);
0be3c7e8 »
2008-02-14 untabified all of yaws
407 {error, Reason} ->
408 io:format("You failed to read the ctlfile ~s~n"
409 "error was: <~p>~n"
410 "specify by <-I id> which yaws system you want "
411 " to control~n",
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
412 [yaws:ctl_file(SID), Reason]),
413 timer:sleep(10),
414 erlang:halt(3);
0be3c7e8 »
2008-02-14 untabified all of yaws
415 {ok, Socket, Key} ->
5207102c »
2008-05-17 Added debug dump functionality
416 gen_tcp:send(Socket, term_to_binary({Term, Key})),
417 Ret = s_cmd(Socket, SID, 0),
418 timer:sleep(40), %% sucks bigtime, we have no good way to flush io
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
419 case Ret of
54139d81 »
2009-03-10 prepare for 1.81
420 ok when Term == stop ->
421 %% wait for Yaws node to truly stop.
422 case gen_tcp:recv(Socket, 0) of
423 {error, closed} ->
424 erlang:halt(0);
425 Other ->
426 io:format("~p~n", [Other]),
427 erlang:halt(3)
428 end;
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
429 ok ->
430 erlang:halt(0);
431 error ->
432 erlang:halt(4)
433 end
434 end.
38fb85e6 »
2002-04-30 ""
435
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
436
5207102c »
2008-05-17 Added debug dump functionality
437 s_cmd(Fd, SID, Count) ->
438 case gen_tcp:recv(Fd, 0) of
439 {ok, Bin} ->
440 io:format("~s", [binary_to_list(Bin)]),
441 s_cmd(Fd, SID, Count+1);
442 {error, closed} when Count > 0 ->
443 gen_tcp:close(Fd);
444 Err ->
445 io_lib:format("yaws server for yaws id <~p> not "
446 "responding: ~p ~n", [SID, Err]),
447 error
448 end.
449
3dc56a7b »
2002-09-12 javascript support in ehtml
450
38fb85e6 »
2002-04-30 ""
451
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
452 %% List existing yaws nodes on this machine for this user
d659ba32 »
2004-05-26 added a 'yaws -ls' command that lists all yaws servers on localhost
453 ls(_) ->
d63642ed »
2009-12-14 do not pass the --id option if the default id is used
454 Dir = filename:join([yaws:tmpdir(), "yaws"]),
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
455 case file:list_dir(Dir) of
0be3c7e8 »
2008-02-14 untabified all of yaws
456 {ok, List} ->
457 io:format("~-15s~-10s~-10s~n",
458 ["Id", "Status", "Owner"]),
459 io:format("-------------------------------------~n",[]),
460 lists:foreach(
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
461 fun(IdDir) ->
462 lls(IdDir)
0be3c7e8 »
2008-02-14 untabified all of yaws
463 end, List);
464 _ ->
465 ok
d659ba32 »
2004-05-26 added a 'yaws -ls' command that lists all yaws servers on localhost
466 end,
467 init:stop().
6dc4cca7 »
2004-05-25 ""
468
469
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
470 lls(IdDir) ->
471 CtlFile = yaws:ctl_file(IdDir),
c9778e01 »
2006-04-27 added support for 2 additional configure
472 case {file:read_file_info(CtlFile),
0be3c7e8 »
2008-02-14 untabified all of yaws
473 file:read_file(CtlFile)} of
474 {{ok, FI}, {error, eacces}} ->
475 User = yaws:uid_to_name(FI#file_info.uid),
476 io:format("~-15s~-10s~-10s~n",
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
477 [IdDir, "noaccess", User]);
0be3c7e8 »
2008-02-14 untabified all of yaws
478 {{ok, FI}, {ok, _Bin}} ->
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
479 Running = case connect(IdDir) of
0be3c7e8 »
2008-02-14 untabified all of yaws
480 {ok, Sock, _Key} ->
481 gen_tcp:close(Sock),
482 "running";
483 {error, timeout} ->
484 "hanging??";
485 {error, eacces} ->
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
486 "noaccess";
0be3c7e8 »
2008-02-14 untabified all of yaws
487 _Err ->
488 "stopped"
489 end,
490 User = yaws:uid_to_name(FI#file_info.uid),
491 io:format("~-15s~-10s~-10s~n",
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
492 [IdDir, Running, User]);
0be3c7e8 »
2008-02-14 untabified all of yaws
493 _ ->
494 ok
c105945d »
2008-04-02 Redid the code which decides where the ctldir resides, now it always …
495 end.
d659ba32 »
2004-05-26 added a 'yaws -ls' command that lists all yaws servers on localhost
496
0be3c7e8 »
2008-02-14 untabified all of yaws
497
6dc4cca7 »
2004-05-25 ""
498
38fb85e6 »
2002-04-30 ""
499 %% send a hup (kindof) to the yaws server to make it
500 %% reload its configuration and clear its caches
501
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
502 hup([SID]) ->
503 actl(SID, hup).
38fb85e6 »
2002-04-30 ""
504
3dc56a7b »
2002-09-12 javascript support in ehtml
505
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
506 %% stop a daemon
0be3c7e8 »
2008-02-14 untabified all of yaws
507 stop([SID]) ->
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
508 actl(SID, stop).
38fb85e6 »
2002-04-30 ""
509
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
510 %% query a daemon for status/stats
511 status([SID]) ->
512 actl(SID, status).
513
514 load(X) ->
515 [SID | Modules] = lists:reverse(X),
516 actl(SID, {load, Modules}).
caa1a726 »
2003-07-16 Added command `-load' to yaws script.
517
6c843784 »
2004-03-22 ""
518 check([Id, File| IncludeDirs]) ->
92bafb48 »
2006-03-09 removed the ability change userid, also stopped writing to /tmp/yaws …
519 GC = yaws_config:make_default_gconf(false, undefined),
2f51c682 »
2002-11-20 -check arg
520 GC2 = GC#gconf{include_dir = lists:map(fun(X) -> atom_to_list(X) end,
0be3c7e8 »
2008-02-14 untabified all of yaws
521 IncludeDirs),
522 id = atom_to_list(Id)
523 },
745bb4a6 »
2004-03-22 ""
524 yaws_server:setup_dirs(GC2),
9ce9a254 »
2004-03-22 ""
525 put(sc, #sconf{}),
526 put(gc, GC2),
a7e93df1 »
2006-08-28 patch from Magnus froberg to get better control over the files genera…
527 put(use_yfile_name, true),
ef3a52a2 »
2004-03-16 Removed the atoms in parse_post and parse query, backwards incompatib…
528 case yaws_compile:compile_file(atom_to_list(File)) of
0be3c7e8 »
2008-02-14 untabified all of yaws
529 {ok, [{errors, 0}| _Spec]} ->
530 timer:sleep(100),erlang:halt(0);
531 % init:stop();
532 _Other ->
533 timer:sleep(100),erlang:halt(1)
534 % init:stop()
2f51c682 »
2002-11-20 -check arg
535 end.
536
dc00e526 »
2004-03-10 postvar bug by hal snyder, added yaws_api:query_url/1 added the id su…
537 %% control a daemon http/traffic tracer
538 trace([What, SID]) ->
539 actl(SID, {trace, What}).
540
5207102c »
2008-05-17 Added debug dump functionality
541 debug_dump([SID]) ->
542 actl(SID, debug_dump).
543
dbaab8bd »
2009-06-12 Stats command
544 stats([SID]) ->
545 actl(SID, stats).
38fb85e6 »
2002-04-30 ""
546
Something went wrong with that request. Please try again.