Skip to content

Commit

Permalink
doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cschiewek committed Sep 27, 2021
1 parent ff78d9f commit bc46b1a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,37 @@ def deps do
end
```

See the [`Foreperson`](https://hexdocs.pm/foreperson/Foreperson.html#content) module doc for configuration options.
## Configuration

Foreperson has 2 configuration options:

`wait:`

The amount of time to pause before finalizing startup. This is useful if the configured process isn't instantly ready.
For example, if your elixir app uses `ecto` and you want to use `foreperson` to start a `postgres` instance, you can set a
wait time to ensure postgres is ready before `ecto` tries to connect.

`processes:`

A list of exertnal processes that you want to start. The syntax is the similar to [Phoenix endpoint watchers](https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-runtime-configuration).
The key is the commmand to run, followed by a list of strings representing command args,
followed by a keyword list of options.

The available options are:
- `:wrap`: Use a [zombie process wrapper](https://hexdocs.pm/elixir/master/Port.html#module-zombie-operating-system-processes). Defaults to `true`.
- `:into`: Injects the result into the given collectable. Defaults to `Foreperson.stream(cmd)` where `cmd` is the name of the process.
- `:stderr_to_stdout` - redirects stderr to stdout. Defaults to `true`.
- All the options available to [System.cmd/3](https://hexdocs.pm/elixir/System.html#cmd/3-options)

### Example
```elixir
config :foreperson,
wait: 500, # Wait 500ms
processes: [
postgres: [], # Run postgres with no command args
"redis-server": ["--loglevel", "warning", wrap: false] # Run redis, and don't use the wrapper script.
]
```

## Running in seperate process or shell

Expand Down
34 changes: 1 addition & 33 deletions lib/foreperson.ex
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
defmodule Foreperson do
@moduledoc """
# Configuration
Foreperson has 2 configuration options:
`wait:`
The amount of time to pause before finalizing startup. This is useful if the configured process isn't instantly ready.
For example, if your elixir app uses `ecto` and you want to use `foreperson` to start a `postgres` instance, you can set a
wait time to ensure postgres is ready before `ecto` tries to connect.
`processes:`
A list of exertnal processes that you want to start. The syntax is the similar to [Phoenix endpoint watchers](https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-runtime-configuration).
The key is the commmand to run, followed by a list of strings representing command args,
followed by a keyword list of options.
The available options are:
- `:wrap`: Use a [zombie process wrapper](https://hexdocs.pm/elixir/master/Port.html#module-zombie-operating-system-processes). Defaults to `true`.
- `:into`: Injects the result into the given collectable. Defaults to `IO.stream(:stdio, :line)`.
- `:stderr_to_stdout` - redirects stderr to stdout. Defaults to `true`.
- All the options available to [System.cmd/3](https://hexdocs.pm/elixir/System.html#cmd/3-options)
### Example
```
config :foreperson,
wait: 500, # Wait 500ms
processes: [
postgres: [], # Run postgres with no command args
"redis-server": ["--loglevel", "warning", wrap: false] # Run redis, and don't use the wrapper script.
]
```
"""
@moduledoc false

def stream(prefix) do
%Foreperson.Formatter{prefix: prefix}
Expand Down
6 changes: 1 addition & 5 deletions lib/foreperson/formatter.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
defmodule Foreperson.Formatter do
@moduledoc """
Module that implements Collectable in order to prefix output destined for :stdio
Basically the same as IO.stream(:stdio, :line), but with the prefix support.
"""
@moduledoc false
defstruct prefix: nil

defimpl Collectable do
Expand Down
20 changes: 17 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
defmodule Foreperson.MixProject do
use Mix.Project

@version "0.1.3"
@source_url "https://github.com/cschiewek/foreperson"

def project do
[
app: :foreperson,
name: "foreperson",
version: "0.1.2",
version: @version,
elixir: "~> 1.11",
start_permanent: Mix.env() == :prod,
description: "Process runner for external dependencies in local dev environments",
source_url: @source_url,
deps: deps(),
package: package()
package: package(),
docs: docs()
]
end

Expand All @@ -35,8 +40,17 @@ defmodule Foreperson.MixProject do
[
maintainers: ["Curtis Schiewek"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/cschiewek/foreperson"},
links: %{"GitHub" => @source_url},
files: ~w(lib priv LICENSE.md mix.exs README.md .formatter.exs)
]
end

defp docs do
[
main: "readme",
extras: ["README.md"],
source_ref: "v#{@version}",
source_url: @source_url
]
end
end

0 comments on commit bc46b1a

Please sign in to comment.