Current section
Files
Jump to
Current section
Files
guides/4.deployment.md
# Deployment
## Using without Releases
It's recommended to create an escript or mix task to perform the
Realbook operations. Guidelines for this process will be forthcoming.
## Deployment using Mix Releases
### With scripts in a generic location.
0. Create an entrypoint function (e.g. `MyApp.go/1`). Let's say
this function takes the `:script_dir` as a parameter and sets that
application, then launches the script(s)
1. Upload your scripts (and assets) to your provisioning server (for
example `~/my_scripts`)
2. Perform a release and transfer your application to the provisioning
server.
3. Execute the realbooks.
```bash
> path/to/release/my_app eval 'MyApp.go "~/my_scripts"'
```
### With scripts and assets in the priv/ directory
0. store your scripts and assets in, for example `priv/scripts` and `priv/assets`
1. create an entrypoint function that sets `:script_dir` as follows:
```elixir
script_dir = :my_app
|> :code.priv_dir
|> Path.join("scripts")
Application.put_env(:realbook, :script_dir, script_dir)
```
2. repeat with `:assets_dir`
3. Perform a release and transfer the application to the provisioning
server.
4. Execute the realbooks.
```bash
> path/to/release/my_app eval 'MyApp.go'
```
The advantage to the latter method is that it allows you to package your
scripts with your deployment. If for some reason you want to keep them
separate, (for example, if they are shared in a repo between multiple
projects) then you should use the former method.
## Running in standalone mode
### NB this procedure may change
If you don't want to ship code in a specific project, you can deploy
Realbook in "standalone" mode. Clone the realbook project from
https://github.com/ityonemo/realbook and perform a mix release by
running `MIX_ENV=prod mix release` from the realbook directory. The
release will be in `_build/prod/rel/realbook` and that directory can
be shipped to your target system (be sure to match operating systems
and kernels).
Once shipped, you should create a shell script that will help your
system run, for example:
```shell
#!/bin/sh
realbook/bin/realbook eval 'import Realbook; \
Application.set_env(:realbook, :script_dir, "path/to/script/dir"); \
Application.set_env(:realbook, :asset_dir, "path/to/asset/dir"); \
Realbook.run("base_script.exs")'
```