2011-03-06 2 views

답변

7

데모 응용 프로그램에서 mywebdemo_sup.erl을 다음과 같이 변경하면 여러 개의 리스너를 얻는 데 성공했습니다. 나는 그것을 그 이상으로 테스트하지는 않았지만 당신을 시작하기에 충분할만큼 잘하면.

init([]) -> 
    Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end, 
    {ok, Dispatch} = file:consult(filename:join(
        [filename:dirname(code:which(?MODULE)), 
        "..", "priv", "dispatch.conf"])), 
    WebConfig = [ 
     {name, one}, 
     {ip, Ip}, 
     {port, 8000}, 
     {log_dir, "priv/log"}, 
     {dispatch, Dispatch}], 
    Web = {one, 
     {webmachine_mochiweb, start, [WebConfig]}, 
     permanent, 5000, worker, dynamic}, 
    WebSSLConfig = [ 
      {name, two}, 
      {ip, Ip}, 
      {port, 8443}, 
      {ssl, true}, 
      {ssl_opts, [{certfile, "/tmp/api_server.crt"}, 
       {cacertfile,"tmp/api_server.ca.crt"}, 
       {keyfile, "/tmp/api_server.key"}]}, 
      {log_dir, "priv/log"}, 
      {dispatch, Dispatch}], 
    WebSSL = {two, 
      {webmachine_mochiweb, start, [WebSSLConfig]}, 
      permanent, 5000, worker, dynamic}, 
    Processes = [Web, WebSSL], 
    {ok, { {one_for_one, 10, 10}, Processes} }. 
+1

대단히 감사드립니다. – noenzyme

+1

매력처럼 작동합니다! 감사. – noenzyme