Skip to content

Commit

Permalink
Merge pull request #2 from AstRonin/cluster
Browse files Browse the repository at this point in the history
Cluster
  • Loading branch information
AstRonin authored Apr 1, 2017
2 parents fb0230a + c8018a2 commit a538d6a
Show file tree
Hide file tree
Showing 14 changed files with 602 additions and 193 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ and you can send message, for example through the [Tor](https://torproject.org/)

- Erlang 18.1+

## Documentation

Read documentation in [Wiki](https://github.com/AstRonin/sgi/wiki).

## Upgrade

Read [UPGRADE](https://github.com/AstRonin/sgi/blob/master/UPGRADE.md) before installation new version.

## Try Samples

### Sample 1 - Add a content from other languages inside of your Site.
Expand Down
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Upgrading Instructions

### From 0.7.0 To 0.8.0

- Configuration tuple list changed to map in `sys.config`.
- Added support of cluster in `sgi_n2o_fcgi_handler` and `sgi_n2o_uwsgi_handler`.

2 changes: 2 additions & 0 deletions samples/apps/review2/src/config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ log_modules() -> % any
sgi_sup,
sgi_arbiter,
sgi_socks5,
sgi_monitoring,
sgi_cluster,

%% n2o_async,
%% n2o_proto,
Expand Down
141 changes: 73 additions & 68 deletions samples/sys.config
Original file line number Diff line number Diff line change
@@ -1,74 +1,79 @@
[
{n2o, [{port,8000},
{app,review},
{upload,"./apps/review/priv/static/"},
{search,"/Users/5HT/depot/synrc/synrc.com/apps/*/doc/web/*.htm"},
{route,routes},
{mq,n2o_mq},
{formatter,bert},
{log_modules,config},
{log_level,config},
{log_backend,n2o_log},
{session,n2o_session},
{auto_session,disabled},
{origin,<<"*">>},
{bridge,n2o_cowboy},
{pickler,n2o_pickle},
{erroring,n2o_error},
{event,pickle}]},
{kvs, [{dba,store_mnesia},
{schema, [kvs_user, kvs_acl, kvs_feed, kvs_subscription ]} ]},
{sgi, [
{servers, [
[{name, default},
{address, localhost},
{port, 9000}, %% default port to FastCGI
{timeout, 60000},
{weight, 2},
{start_connections, 2},
{max_connections, 10}, %% run N processes with 1 connection on each process. Count cannot be bigger then children of fcgi processes
{max_fails, 5},
{failed_timeout, 60}], % failed_timeout in seconds
[{name, aaa},
{address, localhost},
{port, 9001},
{timeout, 60000},
{weight, 5},
{start_connections, 2},
{max_connections, 4},
{max_fails, 5},
{failed_timeout, 60}]
]},
{n2o, [{port, 8000},
{app, review},
{upload, "./apps/review/priv/static/"},
{search, "/Users/5HT/depot/synrc/synrc.com/apps/*/doc/web/*.htm"},
{route, routes},
{mq, n2o_mq},
{formatter, bert},
{log_modules, config},
{log_level, config},
{log_backend, n2o_log},
{session, n2o_session},
{auto_session, disabled},
{origin, <<"*">>},
{bridge, n2o_cowboy},
{pickler, n2o_pickle},
{erroring, n2o_error},
{event, pickle}]},
{kvs, [{dba, store_mnesia},
{schema, [kvs_user, kvs_acl, kvs_feed, kvs_subscription]}]},
{sgi, [{servers, [
#{name => default,
address => localhost,
port => 9000, %% default port to FastCGI
timeout => 60000,
weight => 2,
start_connections => 2,
max_connections => 10, %% run N processes with 1 connection on each process. Count cannot be bigger then children of fcgi processes
max_fails => 5,
failed_timeout => 60}, % failed_timeout in seconds
#{name => aaa,
address => localhost,
port => 9001,
timeout => 60000,
weight => 5,
start_connections => 2,
max_connections => 4,
max_fails => 5,
failed_timeout => 60}]},

%% {proxy, #{type => socks5, %% Settings of proxy
%% address => localhost,
%% port => 9050,
%% timeout => 60000,
%% username => <<"username">>,
%% password => <<"password">>
%% }},
%% {proxy, #{type => socks5, %% Settings of proxy
%% address => localhost,
%% port => 9050,
%% timeout => 60000,
%% username => <<"username">>,
%% password => <<"password">>
%% }},

{balancing_method, priority}, % priority | blurred, priority is default
{multiplexed, unknown}, % unknown | 1 | 0
{response_timeout, 600000}, % 1 minute
{vhosts, [ %% settings for family of cgi interfaces
[
{server_name, "phphost.com"}, %% set your server name(domain), for local tests add line <127.0.0.1 phphost.com> into "/etc/hosts" (in Linux), "C:\Windows\System32\drivers\etc\hosts"(in Windows)
{aliase, "localhost"},
{root, "/home/roman/dev/sgi/samples/cgi-scripts/php"}, %% set you FULL path to your codes
{index, "index.php"}%, %% default index file
%% rewrite very simple and support 2 cases: equal path and all("*"), you can remove it line if don't needed
%%{rewrite, [{"*", "index.php"}]}
],
[
{server_name, "yourhost2.com"}, %% set your server name(domain)
{aliase, "localhost"},
{root, "/usr/local/www/yourhost2.com"}, %% set you full path to your codes
{index, "index.php"}, %% default index file
%% rewrite very simple and support 2 cases: equal path and all("*"), you can remove it line if don't needed
{rewrite, [{"*", "index.php"}]}
]

%% {cluster, #{
%% nodes => ['[email protected]'],
%% syncr_interval => 60000,
%% response_timeout => 600000,
%% cpu_overload => 80, % max percent of loading when need call to cluster
%% mem_overload => 80 % max percent of loading when need call to cluster
%% }},

{balancing_method, priority}, % priority | blurred, priority is default
{multiplexed, unknown}, % unknown | 1 | 0
{response_timeout, 600000}, % 1 minute
{vhosts, [ %% settings for family of cgi interfaces
#{server_name => "phphost.com",
alias => "localhost",
root => "/home/roman/dev/sgi/samples/cgi-scripts/php",
index => "index.php" %, %% default index file
%% rewrite very simple and support 2 cases: equal path and all("*"), you can remove it line if don't needed
%%rewrite => [{"*", "index.php"}]
},
#{server_name => "yourhost2.com", %% set your server name(domain)
alias => "localhost",
root => "/usr/local/www/yourhost2.com", %% set you full path to your codes
index => "index.php", %% default index file
%% rewrite very simple and support 2 cases: equal path and all("*"), you can remove it line if don't needed
rewrite => [{"*", "index.php"}]
}
]}
]},
]},
"sys-local.config"
].
2 changes: 1 addition & 1 deletion src/sgi.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, sgi, [
{description, "Socket Gateway Interface"},
{vsn, "0.7.0"},
{vsn, "0.8.0"},
{registered, [sgi_arbiter, sgi_multiplexer, sgi_sup]},
{modules, []},
{applications, [kernel, stdlib, sasl, os_mon, n2o]},
Expand Down
4 changes: 3 additions & 1 deletion src/sgi_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
-behaviour(application).
-export([start/2, stop/1]).

start(_StartType, _StartArgs) -> sgi_sup:start_link().
start(_StartType, _StartArgs) ->
%% sgi_monitoring:save_stat(),
sgi_sup:start_link().
stop(_State) -> ok.
Loading

0 comments on commit a538d6a

Please sign in to comment.