Sidecar v0.5.0 Sidecar.Process View Source

Supervises a single sidecar process

It is recommended one uses Sidecar.Supervisor to run sidecar processes, rather than using this module manually.

Link to this section Summary

Types

A command that starts a sidecar process

Options used to start a sidecar process

Functions

Start a supervised sidecar process.

Link to this section Types

Specs

command() ::
  String.t() | (() -> String.t()) | [String.t()] | (() -> [String.t()])

A command that starts a sidecar process

If a function, the function will be evaluated just before the sidecar process starts.

A command that is a string or a function returning a string will be split on whitespace.

Examples

The command is the value in each of these keyword lists.

A string

[ngrok: "ngrok http 4000"]

A list of strings

[ngrok: ~w(ngrok http 4000)]

A function returning a string

[ngrok: fn -> "ngrok http #{MyApp.Endpoint.config(:http)[:port]}" end]

A function returning a list of strings

[ngrok: fn -> ["ngrok", "http", MyApp.Endpoint.config(:http)[:port]] end]

Specs

init_opts() :: [name: atom(), command: command()]

Options used to start a sidecar process

  • name An identifier for the process
  • command The command to run, which is passed to Port.open/2 using {:spawn, command}. If the command is a function, the function is evaluated just before the sidecar process is started. Its return value will be the command.

Link to this section Functions

Specs

start_link(init_opts()) :: GenServer.on_start()

Start a supervised sidecar process.