View Source BEAMNotify (beam_notify v1.1.1)
Send a message to the BEAM from a shell script
Summary
Functions
Return the path to beam_notify
Returns a specification to start this module under a supervisor.
Return the OS environment needed to call $BEAM_NOTIFY
Start the BEAMNotify message receiver
Types
Callback for dispatching notifications
BEAMNotify calls the dispatcher function whenever a message comes in. The
first parameter is the list of arguments passed to $BEAM_NOTIFY
. The
second argument is a map containing environment variables. Whether or
not the map is populated depends on the options to start_link/1
.
@type options() :: [ name: binary() | atom(), path: Path.t(), mode: non_neg_integer(), dispatcher: dispatcher(), report_env: boolean(), recbuf: non_neg_integer() ]
BEAMNotify takes the following options
:name
- a unique name for this notifier. This is required if you expect to run multiple BEAMNotify GenServers at a time.:dispatcher
- a function to call when a notification comes in:path
- the path to use for the named socket. A path in the system temporary directory is the default.:mode
- the permissions to apply to the socket. Should be an octal number eg: 0o660 for read/write owner/group, no access to everyone else:report_env
- set totrue
to report environment variables in addition to commandline argument. Defaults tofalse
:recbuf
- receive buffer size. If you're sending a particular large amount of data and getting errors from:erlang.binary_to_term(data)
, try making this bigger. Defaults to 8192.
Functions
@spec bin_path() :: Path.t()
Return the path to beam_notify
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec env(pid() | binary() | atom() | keyword()) :: Enumerable.t()
Return the OS environment needed to call $BEAM_NOTIFY
This returns a map that can be passed directly to System.cmd/3
via its
:env
option.
This function can be passed different things based on what's convenient.
If you're setting up
child_spec
's for a supervision tree and need the environment to pass in anotherchild_spec
, call this with the same options that you'd pass tostart_link/1
. This is a very common use.If you called
start_link/1
manually and have the pid, call it with the pid.If you only have the name that was passed to
start_link/1
, then call it with the name. The name alone is insufficient for returning the$BEAM_NOTIFY_OPTIONS
environment variable, so theBEAMNotify
GenServer must be running. If you're in a chicken-and-egg situation where you're setting up a supervision tree, but it hasn't been started yet, see option 1.
@spec start_link(options()) :: GenServer.on_start()
Start the BEAMNotify message receiver