https://github.com/ferd/start_wrap
Dumb Wrapper to make full releases possible in Erlang with a 'main' loop
https://github.com/ferd/start_wrap
Last synced: about 2 months ago
JSON representation
Dumb Wrapper to make full releases possible in Erlang with a 'main' loop
- Host: GitHub
- URL: https://github.com/ferd/start_wrap
- Owner: ferd
- Created: 2014-09-03T12:57:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-03T13:01:40.000Z (over 10 years ago)
- Last Synced: 2025-01-21T01:25:21.039Z (3 months ago)
- Language: Erlang
- Size: 969 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dumb Wrapper to make full releases possible in Erlang with a 'main' loop
Because people don't want to wait until they learned what a release is, releases are more complex, and they want to ship something simpler than escripts
This uses a `supervisor_bridge` process to end up supervising any random piece of code you have.
Here are two random programs you can write:
```erlang
-module(hello_world).
-export([main/1]).main(_) ->
io:format("Hello, world!~n"),
0.
```And
```erlang
-module(hello_parallel_world).
-export([main/1]).main(Args) ->
run(proplists:get_value(concurrency, Args)),
timer:sleep(100),
0.run([Val]) ->
[spawn(fun() -> io:format("Hello, world (~p)!~n", [N]) end)
|| N <- lists:seq(1, list_to_integer(Val))].```
## How to run code
Build the code you want to run:
```bash
$ erlc *.erl
```Build the harness:
```bash
$ rebar get-deps compile
```Run your own code:
```bash
$ erlc *.erl && _rel/start_wrap/bin/start_wrap -pa `pwd` -start_wrap module hello_world
$ erlc *.erl && ./_rel/bin/start_wrap -pa `pwd` -start_wrap module hello_parallel_world -concurrency 5
```And there you go.