update documentation
This commit is contained in:
@@ -25,6 +25,9 @@ all: erluv erluv_test
|
|||||||
liberluv.o:
|
liberluv.o:
|
||||||
$(CC) $(INCLUDES) -c liberluv.c -o $@
|
$(CC) $(INCLUDES) -c liberluv.c -o $@
|
||||||
|
|
||||||
|
t!
|
||||||
|
$(CC) $(CFLAGS) $@.c -o $@
|
||||||
|
|
||||||
erluv: liberluv.o
|
erluv: liberluv.o
|
||||||
$(CC) $(CFLAGS) liberluv.o $@.c -o $@
|
$(CC) $(CFLAGS) liberluv.o $@.c -o $@
|
||||||
|
|
||||||
|
|||||||
@@ -90,10 +90,6 @@ main(int argc, char *argv[]) {
|
|||||||
uv_loop_t *loop;
|
uv_loop_t *loop;
|
||||||
create_loop(loop);
|
create_loop(loop);
|
||||||
|
|
||||||
/* create a tcp structure and init it */
|
|
||||||
uv_tcp_t server;
|
|
||||||
uv_tcp_init(loop, &server);
|
|
||||||
|
|
||||||
/* connect to erlang node */
|
/* connect to erlang node */
|
||||||
ei_cnode ec;
|
ei_cnode ec;
|
||||||
ei_connect_init(&ec, node_name, cookie, creation);
|
ei_connect_init(&ec, node_name, cookie, creation);
|
||||||
@@ -103,9 +99,6 @@ main(int argc, char *argv[]) {
|
|||||||
if ((sockfd = ei_connect(&ec, node_target)) < 0)
|
if ((sockfd = ei_connect(&ec, node_target)) < 0)
|
||||||
fprintf(stderr, "ERROR: ei_connect failed\n");
|
fprintf(stderr, "ERROR: ei_connect failed\n");
|
||||||
|
|
||||||
/* open the tcp socket with */
|
|
||||||
uv_tcp_open(&server, sockfd);
|
|
||||||
|
|
||||||
/* create an erlang pid
|
/* create an erlang pid
|
||||||
erlang_pid pid;
|
erlang_pid pid;
|
||||||
ei_make_pid(&ec, &pid);
|
ei_make_pid(&ec, &pid);
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ Where we learn how to create a process.
|
|||||||
|
|
||||||
Where we learn how to create a worker pool.
|
Where we learn how to create a worker pool.
|
||||||
|
|
||||||
## Merging Erlang C-node and libuv
|
## Merging Erlang C-node and libuv (first model)
|
||||||
|
|
||||||
Where we merge Erlang, C-node and libuv together to make amazing
|
Where we merge Erlang, C-node and libuv together to make amazing
|
||||||
things.
|
things.
|
||||||
@@ -232,6 +232,77 @@ orders, like creating a worker with defined arguments and environment
|
|||||||
but, it can also kill them or forward the content of the children to
|
but, it can also kill them or forward the content of the children to
|
||||||
the dispatcher.
|
the dispatcher.
|
||||||
|
|
||||||
|
## Merging Erlang C-node and libuv (second model)
|
||||||
|
|
||||||
|
```txt
|
||||||
|
__________________
|
||||||
|
| |
|
||||||
|
| erluv process |
|
||||||
|
_________________ | ____________ |
|
||||||
|
| | | | | | /
|
||||||
|
| Erlang-node |<--+---->| erluv_main | | < privsep & fork
|
||||||
|
| _______ | | | |____________| | \
|
||||||
|
| / \_ | | | _____||______ |
|
||||||
|
| ( process )\_ | | | | | | /
|
||||||
|
| \_______/ )\ | +---->| erluv_child | | < shared conn
|
||||||
|
| \_______/ ) | | |_____________| | \
|
||||||
|
| \_______/ | | ____|___ |
|
||||||
|
| | |_ | |_ ____| /
|
||||||
|
|_________________| | worker | |_ < app workers
|
||||||
|
|________| | | \
|
||||||
|
|________| |
|
||||||
|
|________|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Erlang-node spawn a c-node (with erlang-node user) or a c-node is
|
||||||
|
manually spawned by a user on the system (e.g. privileged or
|
||||||
|
unpriviliged one).
|
||||||
|
|
||||||
|
2. `erluv_main` start a connection to Erlang-node by using
|
||||||
|
credentials given by the user from configuration file, environment
|
||||||
|
variable or command line argument (e.g. node name, cookie...).
|
||||||
|
|
||||||
|
3. `erluv_main` fork and spawn a new `erluv_child` with privilege
|
||||||
|
separation. If start as root, application will fallback in
|
||||||
|
unprivileged user (e.g. nobody). Connection to Erlang-node is
|
||||||
|
shared to `erluv_child`.
|
||||||
|
|
||||||
|
4. By default, no worker is started. c-node is waiting for
|
||||||
|
instruction.
|
||||||
|
|
||||||
|
5. Erlang-node want to start a new worker and send a data-structure
|
||||||
|
containing argument, environment variables and other useful
|
||||||
|
information to spawn the worker.
|
||||||
|
|
||||||
|
6. The new worker is started and a process is started on the
|
||||||
|
erlang-node at the same time, linking them together.
|
||||||
|
|
||||||
|
7. `stdin`, `stdout` and `stderr` default file descriptors are shared
|
||||||
|
with a stream between the Erlang-node and `erluv_child`/worker.
|
||||||
|
|
||||||
|
8. When the worker die, a message is sent to the corresponding
|
||||||
|
process and can be restarted if desired.
|
||||||
|
|
||||||
|
9. If `erluv_child` crash, `erluv_main` send a message to the node
|
||||||
|
and wait an other to respawn a new child. all processes linking to
|
||||||
|
the worker also die.
|
||||||
|
|
||||||
|
10. If `erluv_main` does not receive a confirmation after
|
||||||
|
`DIE_TIMEOUT`, `erluv_main` die too.
|
||||||
|
|
||||||
|
The c-node name is based on a prefix, by default `erluv_${random}`.
|
||||||
|
|
||||||
|
Each c-node can share their information, like `node_name`, `cookie`,
|
||||||
|
`running` user but can't alter these information.
|
||||||
|
|
||||||
|
By default, environment variable on each worker are not configured.
|
||||||
|
|
||||||
|
|
||||||
|
# Notes
|
||||||
|
|
||||||
|
* multi-hidden note support
|
||||||
|
|
||||||
# Resources
|
# Resources
|
||||||
|
|
||||||
## Libuv
|
## Libuv
|
||||||
|
|||||||
Reference in New Issue
Block a user