4
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
25
25
-include("httpd.hrl").
27
-deprecated({start, 0, next_major_release}).
28
-deprecated({start, 1, next_major_release}).
29
-deprecated({start_link, 1, next_major_release}).
30
-deprecated({start_child, 0, next_major_release}).
31
-deprecated({start_child, 1, next_major_release}).
32
-deprecated({stop, 0, next_major_release}).
33
-deprecated({stop, 1, next_major_release}).
34
-deprecated({stop, 2, next_major_release}).
35
-deprecated({stop_child, 0, next_major_release}).
36
-deprecated({stop_child, 1, next_major_release}).
37
-deprecated({stop_child, 2, next_major_release}).
38
-deprecated({restart, 0, next_major_release}).
39
-deprecated({restart, 1, next_major_release}).
40
-deprecated({restart, 2, next_major_release}).
41
-deprecated({block, 0, next_major_release}).
42
-deprecated({block, 1, next_major_release}).
43
-deprecated({block, 2, next_major_release}).
44
-deprecated({block, 3, next_major_release}).
45
-deprecated({block, 4, next_major_release}).
46
-deprecated({unblock, 0, next_major_release}).
47
-deprecated({unblock, 1, next_major_release}).
48
-deprecated({unblock, 2, next_major_release}).
50
27
%% Behavior callbacks
51
-export([start_standalone/1, start_service/1, stop_service/1, services/0,
55
37
-export([parse_query/1, reload_config/2, info/1, info/2, info/3]).
58
-export([start/0, start/1,
59
start_link/0, start_link/1,
60
start_child/0,start_child/1,
62
stop_child/0,stop_child/1,stop_child/2,
63
restart/0,restart/1,restart/2]).
65
%% Management stuff should be internal functions
67
-export([block/0,block/1,block/2,block/3,block/4,
68
unblock/0,unblock/1,unblock/2]).
70
%% Internal Debugging and status info stuff...
71
%% Keep for now should probably be moved to test catalog
72
-export([get_status/1,get_status/2,get_status/3,
73
get_admin_state/0,get_admin_state/1,get_admin_state/2,
74
get_usage_state/0,get_usage_state/1,get_usage_state/2]).
39
%% Internal debugging and status info stuff...
41
get_status/1, get_status/2, get_status/3,
42
get_admin_state/0, get_admin_state/1, get_admin_state/2,
43
get_usage_state/0, get_usage_state/1, get_usage_state/2
76
46
%%%========================================================================
185
159
{error,not_started}
188
reload(Addr, Port) when is_integer(Port) ->
189
Name = make_name(Addr,Port),
190
case whereis(Name) of
191
Pid when is_pid(Pid) ->
192
httpd_manager:reload(Pid, undefined);
197
163
%%% =========================================================
198
%%% Function: block/0, block/1, block/2, block/3, block/4
201
%%% block(ConfigFile)
204
%%% block(ConfigFile,Mode)
205
%%% block(Addr,Port,Mode)
206
%%% block(ConfigFile,Mode,Timeout)
207
%%% block(Addr,Port,Mode,Timeout)
164
%%% Function: block/3, block/4
165
%%% block(Addr, Port, Mode)
166
%%% block(ConfigFile, Mode, Timeout)
167
%%% block(Addr, Port, Mode, Timeout)
209
169
%%% Returns: ok | {error,Reason}
237
197
%%% Mode -> disturbing | non_disturbing
238
198
%%% Timeout -> integer()
240
block() -> block(undefined,8888,disturbing).
242
block(Port) when is_integer(Port) ->
243
block(undefined,Port,disturbing);
245
block(ConfigFile) when is_list(ConfigFile) ->
246
case get_addr_and_port(ConfigFile) of
248
block(Addr,Port,disturbing);
253
block(Addr,Port) when is_integer(Port) ->
254
block(Addr,Port,disturbing);
256
block(Port,Mode) when is_integer(Port) andalso is_atom(Mode) ->
257
block(undefined,Port,Mode);
259
block(ConfigFile,Mode) when is_list(ConfigFile) andalso is_atom(Mode) ->
260
case get_addr_and_port(ConfigFile) of
262
block(Addr,Port,Mode);
268
block(Addr,Port,disturbing) when is_integer(Port) ->
269
do_block(Addr,Port,disturbing);
270
block(Addr,Port,non_disturbing) when is_integer(Port) ->
271
do_block(Addr,Port,non_disturbing);
273
block(ConfigFile,Mode,Timeout) when is_list(ConfigFile) andalso
274
is_atom(Mode) andalso
275
is_integer(Timeout) ->
276
case get_addr_and_port(ConfigFile) of
278
block(Addr,Port,Mode,Timeout);
284
block(Addr,Port,non_disturbing,Timeout)
285
when is_integer(Port) andalso is_integer(Timeout) ->
286
do_block(Addr,Port,non_disturbing,Timeout);
287
block(Addr,Port,disturbing,Timeout) when is_integer(Port) andalso
288
is_integer(Timeout) ->
289
do_block(Addr,Port,disturbing,Timeout).
291
do_block(Addr,Port,Mode) when is_integer(Port) andalso is_atom(Mode) ->
201
block(Addr, Port, disturbing) when is_integer(Port) ->
202
do_block(Addr, Port, disturbing);
203
block(Addr, Port, non_disturbing) when is_integer(Port) ->
204
do_block(Addr, Port, non_disturbing);
206
block(ConfigFile, Mode, Timeout)
207
when is_list(ConfigFile) andalso
208
is_atom(Mode) andalso
209
is_integer(Timeout) ->
210
case get_addr_and_port(ConfigFile) of
212
block(Addr, Port, Mode, Timeout);
218
block(Addr, Port, non_disturbing, Timeout)
219
when is_integer(Port) andalso is_integer(Timeout) ->
220
do_block(Addr, Port, non_disturbing, Timeout);
221
block(Addr,Port,disturbing,Timeout)
222
when is_integer(Port) andalso is_integer(Timeout) ->
223
do_block(Addr, Port, disturbing, Timeout).
225
do_block(Addr, Port, Mode) when is_integer(Port) andalso is_atom(Mode) ->
292
226
Name = make_name(Addr,Port),
293
227
case whereis(Name) of
294
228
Pid when is_pid(Pid) ->
521
442
%%%--------------------------------------------------------------
523
444
%%%--------------------------------------------------------------
525
start("/var/tmp/server_root/conf/8888.conf").
528
{ok, Pid} = inets:start(httpd, ConfigFile, stand_alone),
533
start("/var/tmp/server_root/conf/8888.conf").
535
start_link(ConfigFile) when is_list(ConfigFile) ->
536
inets:start(httpd, ConfigFile, stand_alone).
541
stop(Port) when is_integer(Port) ->
542
stop(undefined, Port);
543
stop(Pid) when is_pid(Pid) ->
545
stop(ConfigFile) when is_list(ConfigFile) ->
546
old_stop(ConfigFile).
548
stop(Addr, Port) when is_integer(Port) ->
549
old_stop(Addr, Port).
552
start_child("/var/tmp/server_root/conf/8888.conf").
554
start_child(ConfigFile) ->
555
httpd_sup:start_child(ConfigFile).
561
stop_child(undefined, Port).
563
stop_child(Addr, Port) when is_integer(Port) ->
564
httpd_sup:stop_child(Addr, Port).
566
restart() -> reload(undefined, 8888).
568
restart(Port) when is_integer(Port) ->
569
reload(undefined, Port).
570
restart(Addr, Port) ->
573
old_stop(Pid) when is_pid(Pid) ->
575
old_stop(ConfigFile) when is_list(ConfigFile) ->
576
case get_addr_and_port(ConfigFile) of
578
old_stop(Addr, Port);
447
%% start("/var/tmp/server_root/conf/8888.conf").
449
%% start(ConfigFile) ->
450
%% {ok, Pid} = inets:start(httpd, ConfigFile, stand_alone),
455
%% start("/var/tmp/server_root/conf/8888.conf").
457
%% start_link(ConfigFile) when is_list(ConfigFile) ->
458
%% inets:start(httpd, ConfigFile, stand_alone).
463
%% stop(Port) when is_integer(Port) ->
464
%% stop(undefined, Port);
465
%% stop(Pid) when is_pid(Pid) ->
467
%% stop(ConfigFile) when is_list(ConfigFile) ->
468
%% old_stop(ConfigFile).
470
%% stop(Addr, Port) when is_integer(Port) ->
471
%% old_stop(Addr, Port).
474
%% start_child("/var/tmp/server_root/conf/8888.conf").
476
%% start_child(ConfigFile) ->
477
%% httpd_sup:start_child(ConfigFile).
482
%% stop_child(Port) ->
483
%% stop_child(undefined, Port).
485
%% stop_child(Addr, Port) when is_integer(Port) ->
486
%% httpd_sup:stop_child(Addr, Port).
488
%% restart() -> reload(undefined, 8888).
490
%% restart(Port) when is_integer(Port) ->
491
%% reload(undefined, Port).
492
%% restart(Addr, Port) ->
493
%% reload(Addr, Port).
495
%% old_stop(Pid) when is_pid(Pid) ->
497
%% old_stop(ConfigFile) when is_list(ConfigFile) ->
498
%% case get_addr_and_port(ConfigFile) of
499
%% {ok, Addr, Port} ->
500
%% old_stop(Addr, Port);
583
old_stop(_StartArgs) ->
505
%% old_stop(_StartArgs) ->
586
old_stop(Addr, Port) when is_integer(Port) ->
587
Name = old_make_name(Addr, Port),
588
case whereis(Name) of
589
Pid when is_pid(Pid) ->
508
%% old_stop(Addr, Port) when is_integer(Port) ->
509
%% Name = old_make_name(Addr, Port),
510
%% case whereis(Name) of
511
%% Pid when is_pid(Pid) ->
519
%% exit(Pid, shutdown).
599
old_make_name(Addr,Port) ->
600
httpd_util:make_name("httpd_instance_sup",Addr,Port).
521
%% old_make_name(Addr,Port) ->
522
%% httpd_util:make_name("httpd_instance_sup",Addr,Port).