-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the hello_world4 example to show how CloudI can be included with …
…a relx release.
- Loading branch information
Showing
10 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.PHONY : all clean release | ||
|
||
CLOUDI_VERSION=1.2.5 | ||
CLOUDI_PATH=/usr/local/lib/cloudi-$(CLOUDI_VERSION)/lib/cloudi_core-$(CLOUDI_VERSION) | ||
|
||
all: src/hello_world4.erl | ||
erlc -pz $(CLOUDI_PATH) -pz $(CLOUDI_PATH)/ebin -o ebin src/hello_world4.erl | ||
|
||
clean: | ||
rm -f ebin/hello_world4.beam | ||
rm -rf release | ||
|
||
release: all reltool.config | ||
../../src/lib/reltool_util/release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Hello World 4 Example | ||
|
||
## PURPOSE | ||
|
||
Provide the simplest example of an Erlang application running within the same | ||
Erlang VM as CloudI, with a CloudI service (`hello_world4.erl`), using relx. | ||
The example uses the same OTP release for both CloudI and the internal CloudI | ||
service. | ||
|
||
## DETAILS | ||
|
||
The approach with the Hello World 4 Example is for CloudI to load the | ||
`hello_world4` application after CloudI has started. The `hello_world4` | ||
application can be specified within the cloudi.conf or provided | ||
dynamically to the CloudI Service API, to start the CloudI service | ||
(separate from the application's supervision hierarchy, if one is present). | ||
Using this method of deployment (within the same OTP release) the | ||
`hello_world4` application file can specify CloudI as a dependency by | ||
listing the `cloudi_core` application as a dependency, unlike the | ||
approach within the `hello_world1` example. | ||
|
||
## USAGE | ||
|
||
To use an Erlang/OTP application file for an internal service with the same | ||
module name: | ||
|
||
$ git clone https://github.com/erlware/relx | ||
$ cd relx | ||
$ make | ||
$ cd .. | ||
$ make | ||
$ relx/relx | ||
$ cd release | ||
$ bin/cloudi start | ||
$ curl http://localhost:6467/examples/hello_world4 | ||
Hello World! | ||
$ bin/cloudi stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[{sasl, [ | ||
{sasl_error_logger, {file, "logs/sasl.log"}}, | ||
{error_logger_mf_dir, "logs"}, | ||
{error_logger_mf_maxbytes, 536870912}, % 512 MB | ||
{error_logger_mf_maxfiles, 128}, | ||
{utc_log, true} | ||
]}, | ||
{ec2nodefinder, [ | ||
{group, "PUT group-name here"}, | ||
{private_key, "PUT private-key-filepath here"}, | ||
{cert, "PUT cert-filepath here"}, | ||
{ping_timeout_sec, 60}, | ||
{ec2_home, "/usr"}, | ||
{ec2_home, "/usr/lib/jvm/java-6-openjdk-amd64/jre"} | ||
]}, | ||
{nodefinder, [ | ||
{addr, {224,0,0,1}}, | ||
{port, 4475}, | ||
{multicast_ttl, 1} | ||
]}, | ||
{cloudi_core, [ | ||
{configuration, "releases/1/cloudi.conf"} | ||
]}]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{acl, [ | ||
]}. | ||
{services, [ | ||
{internal, | ||
"/cloudi/api/", | ||
cloudi_service_api_requests, | ||
[], | ||
none, | ||
5000, 5000, 5000, undefined, undefined, 1, 5, 300, | ||
[]}, | ||
{internal, | ||
"/tests/http/", | ||
cloudi_service_http_cowboy, | ||
[{port, 6467}, {output, internal}], | ||
immediate_closest, | ||
5000, 5000, 5000, undefined, undefined, 1, 5, 300, | ||
[{duo_mode, true}]}, | ||
{internal, | ||
"/examples/", | ||
hello_world4, | ||
[], | ||
none, | ||
5000, 5000, 5000, undefined, undefined, 1, 5, 300, | ||
[]} | ||
]}. | ||
{nodes, [ | ||
]}. | ||
{logging, [ | ||
{file, "log/cloudi.log"} | ||
]}. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%-*-Mode:erlang;coding:utf-8;tab-width:4;c-basic-offset:4;indent-tabs-mode:()-*- | ||
% ex: set ft=erlang fenc=utf-8 sts=4 ts=4 sw=4 et: | ||
|
||
{application, hello_world4, | ||
[{description, "Hello World Example Application"}, | ||
{vsn, "1.3.0"}, | ||
{modules, [ | ||
hello_world4]}, | ||
{registered, []}, | ||
{applications, [ | ||
cloudi_core, | ||
stdlib, | ||
kernel]}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{lib_dirs, | ||
[ | ||
"/usr/local/lib/cloudi-1.2.5/lib" | ||
]}. | ||
{release, {cloudi, "1"}, | ||
[hello_world4, | ||
cloudi_core]}. | ||
|
||
{extended_start_script, true}. | ||
|
||
{output_dir, "release"}. | ||
|
||
{overlay, [ | ||
{copy, "./app.config", "releases/{{rel_vsn}}/sys.config"}, | ||
{copy, "./vm.args", "releases/{{rel_vsn}}/vm.args"}, | ||
{copy, "./cloudi.conf", "releases/{{rel_vsn}}/cloudi.conf"} | ||
]}. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-module(hello_world4). | ||
-behaviour(cloudi_service). | ||
|
||
%% cloudi_service callbacks | ||
-export([cloudi_service_init/3, | ||
cloudi_service_handle_request/11, | ||
cloudi_service_handle_info/3, | ||
cloudi_service_terminate/2]). | ||
|
||
-include_lib("cloudi_core/include/cloudi_logger.hrl"). | ||
|
||
-record(state, | ||
{ | ||
}). | ||
|
||
cloudi_service_init(_Args, _Prefix, Dispatcher) -> | ||
cloudi_service:subscribe(Dispatcher, "hello_world4/get"), | ||
{ok, #state{}}. | ||
|
||
cloudi_service_handle_request(_Type, _Name, _Pattern, _RequestInfo, _Request, | ||
_Timeout, _Priority, _TransId, _Pid, | ||
#state{} = State, _Dispatcher) -> | ||
{reply, <<"Hello World!">>, State}. | ||
|
||
cloudi_service_handle_info(Request, State, _) -> | ||
?LOG_WARN("Unknown info \"~p\"", [Request]), | ||
{noreply, State}. | ||
|
||
cloudi_service_terminate(_, #state{}) -> | ||
ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
## Name of the node | ||
-sname cloudi_hello_world4 | ||
|
||
## Cookie for distributed erlang | ||
-setcookie cloudi_hello_world4 | ||
|
||
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive | ||
## (Disabled by default..use with caution!) | ||
##-heart | ||
|
||
## Enable kernel poll and a few async threads | ||
+K true | ||
+A 5 | ||
|
||
## Increase number of Erlang processes | ||
+P 65536 | ||
|
||
## Increase number of concurrent ports/sockets | ||
-env ERL_MAX_PORTS 32768 | ||
#+Q 32768 # change for R17 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters