github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

noss / iserve

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 18
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 15aad96

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A small http server for erlang. — Read more

  cancel

http://frihjul.net/iserve

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

freenode test 
noss (author)
Mon Mar 23 11:44:40 -0700 2009
commit  15aad962c1b45fdc119af9817d42bab45c7470f5
tree    169f8312276bce358feae7223122cc563a84db67
parent  10e0f96ebfac61b31635e8463b3ea97400824537
iserve / src / iserve_master.erl src/iserve_master.erl
100644 66 lines (43 sloc) 1.476 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%%% File : iserve_master.erl
%%% Author : Christian <chsu79@gmail.com>
%%% Description : Bookkeeping of running servers
 
-module(iserve_master).
-behaviour(gen_server).
 
-export([start_link/1]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
 
%%% Records
-record(state, {supervisor}).
 
%%% API
start_link(SupervisorPid) ->
    gen_server:start_link({local, ?MODULE}, ?MODULE, [SupervisorPid], []).
 
%%% gen_server callbacks
 
init([SupPid]) ->
    %% TODO, look up the sibling server supervisor?
    {ok, #state{supervisor=SupPid}}.
 
handle_call({add_server, Conf}, _From, State) ->
    call_add_server(Conf, State);
handle_call({del_server, Id}, _, State) ->
    call_del_server(Id, State);
handle_call(_Request, _From, State) ->
    {stop, unknown_call, State}.
 
 
handle_cast(info, State) ->
    erlang:display(State),
    {noreply, State};
handle_cast(_Msg, State) ->
    {stop, unknown_cast, State}.
 
 
handle_info(_Info, State) ->
    {noreply, State}.
 
 
terminate(_Reason, _State) ->
    ok.
 
 
code_change(_OldVsn, State, _Extra) ->
    {ok, State}.
 
%%% Internal functions
 
call_add_server({_Starter, _Port, _Callback, _Context}=Conf, S) ->
    {ok, Pid} = iserve_server_sup:add_server(S#state.supervisor, Conf),
    %% TODO: Monitor the little bugger
    Reply = {ok, Pid},
    {reply, Reply, S}.
 
call_del_server(Pid, S) ->
    supervisor:terminate_child(S#state.supervisor, Pid),
    {reply, ok, S}.
 
    
 
    
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server