Embed a Pusher-protocol-compatible websocket server in your own application's supervision tree:
children = [
{PusherServer,
name: MyApp.PusherServer,
port: 4001,
app_key: "my-key",
app_secret: "my-secret",
app_id: "my-app-id"}
]Every option can be omitted; it falls back to the PUSHER_APP_KEY /
PUSHER_APP_SECRET / PUSHER_APP_ID / PORT / PUSHER_WEBHOOK_URL /
PUSHER_ENABLE_CLIENT_MESSAGES / PUSHER_REDIS_URL environment
variables (the same ones the standalone Docker release reads), so this
also works with zero config for the common case of one instance per app.
Running several servers
Add redis_url: "redis://host:6379" (or set PUSHER_REDIS_URL) on every
node and they behave as one: a client connected to node A receives events
triggered through node B, presence is shared, and
member_added/channel_occupied-style events fire once cluster-wide.
Every node must use the same app_id/app_key/app_secret.
Redis is optional — without :redis_url an instance is fully in-memory and
never opens a Redis connection.
Several instances in one app
Running more than one named instance in the same app (e.g. two
different Pusher app_ids on two different ports) works too — just give
each a unique :name. Each instance gets its own channel registry and
presence state; they never see each other's connections or channels.
Summary
Functions
Stops this node from accepting new connections and tells every
currently-connected client to reconnect (a clean pusher:error + close
frame instead of the socket just dying). With several nodes behind a load
balancer, clients reconnect to a node that is still up.
Starts one instance (its supervisor, registry, backend processes and HTTP/WebSocket listener).
Functions
Stops this node from accepting new connections and tells every
currently-connected client to reconnect (a clean pusher:error + close
frame instead of the socket just dying). With several nodes behind a load
balancer, clients reconnect to a node that is still up.
Call this from your own app's shutdown path if you embed PusherServer; the standalone release calls it automatically on SIGTERM.
Starts one instance (its supervisor, registry, backend processes and HTTP/WebSocket listener).
Usually you don't call this directly; add {PusherServer, opts} to your supervision
tree instead. See PusherServer.Config for every option.