Erlang OTP is a complete and reliable large-scale library, is a great success of the predecessors; now try the application inets Web server httpd, write a code call Inets service:
1 -module(INETS_HTTPD). 2 -export([start/0]). 3 4 Start ()5 inets:start (),6 Inets:start (httpd, [{bind_ Address, {192,168,178,130}}, {ipfamily, inet}, {port, 18080}, {service_admin, "[Email protected]"}, {server_name, " Whyang.yang.net "}, {server_root,". "}, {Server_tokens, full}, {document_root,"./html "}, {directory_index,[" main.html "," index.html "]}, {log_format, common}, {error_log,"/var/inets_httpd_error_temp.log "}, {Security_log,"/var/ Inets_httpd_security_temp.log "}, {transfer_log,"/var/inets_httpd_transfer_temp.log "}]).
Compile:
[Email protected] ~~]# L-tr-rw-r--r-- 1 root root 832 Jul 8 19:01 ~]#
Mode of execution 1:
[Email protected] ~]# erl-noshell-s inets_httpd start
Mode of Execution 2:
[Email protected] ~]# erlerlang/OTP [erts-6.4] [source] [64-bit] [async-threads:10] [HiPe] [Kernel-poll: false ]eshell V6. 4 (abort with ^G)1> C (inets_httpd). { OK,INETS_HTTPD}2> Inets_httpd:start (). { OK,<0.50.0>}3>
Browser to see what the server is (incredibly still with the etag tag, this is not advanced):
Look at the "processes" that the Inets service initiated in the Erlang virtual machine (the process that is defined by the Erlang virtual machine beam, not the operating system):
<0.40.0> APPLICATION_MASTER:INIT/4 233 41 0Application_master:main_loop/2 6<0.41.0> APPLICATION_MASTER:START_IT/4 233 49 0Application_master:loop_it/4 5<0.42.0> SUPERVISOR:INETS_SUP/1 233 308 0Inets_sup Gen_server:loop/6 9<0.43.0> SUPERVISOR:FTP_SUP/1 233 52 0Ftp_sup Gen_server:loop/6 9<0.44.0> SUPERVISOR:HTTPC_SUP/1 233 171 0Httpc_sup Gen_server:loop/6 9<0.45.0> SUPERVISOR:HTTPC_PROFILE_SUP/1 233 122 0Httpc_profile_sup Gen_server:loop/6 9<0.46.0> HTTPC_MANAGER:INIT/1 233 78 0Httpc_manager Gen_server:loop/6 9<0.47.0> SUPERVISOR:HTTPC_HANDLER_SUP/1 233 52 0Httpc_handler_sup Gen_server:loop/6 9<0.48.0> SUPERVISOR:HTTPD_SUP/1 987 426 0Httpd_sup Gen_server:loop/6 9<0.49.0> SUPERVISOR:TFTP_SUP/1 233 52 0Tftp_sup Gen_server:loop/6 9<0.50.0> SUPERVISOR:HTTPD_INSTANCE_SUP/1 987 770 0httpd_instance_sup__1 Gen_server:loop/6 9<0.51.0> SUPERVISOR:HTTPD_CONNECTION_SUP/1 610 1163 0Httpd_connection_sup_ Gen_server:loop/6 9<0.52.0> SUPERVISOR:HTTPD_ACCEPTOR_SUP/1 610 420 0httpd_acceptor_sup__1 Gen_server:loop/6 9<0.53.0> HTTPD_ACCEPTOR:ACCEPTOR_INIT/8 1598 3494 0prim_inet:accept0/2 17<0.54.0> SUPERVISOR:HTTPD_MISC_SUP/1 233 41 0httpd_misc_sup__192_1 Gen_server:loop/6 9<0.55.0> HTTPD_MANAGER:INIT/1 2586 5838 0httpd__192_168_178_13 Gen_server:loop/6 9<0.56.0> ERLANG:APPLY/2 233 310 0File_io_server:server_loop/1 3<0.57.0> ERLANG:APPLY/2 233 308 0File_io_server:server_loop/1 3<0.58.0> erlang:apply/2 2586 6748 0File_io_server:server_loop/1 3<0.61.0> httpd_request_handler:init/1 2586 23440 0Gen_server:loop/6 9<0.62.0> HTTPD_REQUEST_HANDLER:INIT/1 4185 12550 0Gen_server:loop/6 9<0.63.0> HTTPD_REQUEST_HANDLER:INIT/1 4185 6476 0Gen_server:loop/6 9<0.64.0> HTTPD_REQUEST_HANDLER:INIT/1 2586 6756 0Gen_server:loop/6 9
There are several processes that are more redundant, such as HTTPC, and TFTP, which is not required here.
Start the Web server inside the ERLANG/OTP