https://github.com/cloud8421/code_reloader
Experimental (and hacky) recompile support for Elixir via a tcp socket
https://github.com/cloud8421/code_reloader
Last synced: about 1 month ago
JSON representation
Experimental (and hacky) recompile support for Elixir via a tcp socket
- Host: GitHub
- URL: https://github.com/cloud8421/code_reloader
- Owner: cloud8421
- Created: 2016-02-12T10:52:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-09T10:37:25.000Z (over 10 years ago)
- Last Synced: 2025-03-02T13:26:29.074Z (over 1 year ago)
- Language: Elixir
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CodeReloader
Experimental application that allows to recompile and restart an Elixir application via a tcp command.
## Installation
This package can be installed via:
1. Add code_reloader to your list of dependencies in `mix.exs`:
def deps do
[{:code_reloader, github: "cloud8421/code_reloader", only: :dev}]
end
2. Ensure code_reloader is started before your application:
def application do
[applications: [:plug, :cowboy, etc...] ++ code_reloader_app(Mix.env)]
end
defp code_reloader_app(:dev) do
[:code_reloader]
end
defp code_reloader_app(_), do: []
**IMPORTANT** Please make sure that the application is started only in
`dev` as shown in the example above.
3. Configure the needed port in `config.exs`:
config :code_reloader,
port: 9999
## Usage
Once up, you can send tcp commands to the istance, for example with [nmap](https://nmap.org/).
$ echo "recompile" | ncat localhost 9999
## Custom recompile
In some instances, for example when using cowboy and ranch, the default recompile task may fail.
In that case you can override the default behaviour by:
1. Defining a custom callbacks module
```elixir
defmodule MyCallbacks do
use CodeReloader.Callbacks
def recompile do
Application.stop(:cowboy)
Application.stop(:ranch)
super
end
end
```
2. Add it to the configuration:
config :code_reloader,
port: 9999,
callbacks_module: MyCallbacks