You can add AnyCable to your application by adding Processes to your app for the gRPC and websocket servers.
First, you'll need to
install AnyCable.
Next, you'll want to generate the binstub provided by AnyCable by running:
bundle exec rails g anycable:bin
Environment Variables
Then we'll want to add the following environment variable to configure AnyCable.
ANYCABLE_PORT=8080
This assigns a unique port to AnyCable to avoid conflicting with your application web server $PORT environment variable assigned by Hatchbox.
Processes
Visit the Process tab of your App and add the processes there. They will be added a systemd services that will be monitored and restarted automatically in case of a crash.
Name: anycable
Start command: bundle exec anycable
Name: anycable-go
Start command: bin/anycable-go
The rest of the process options can be left as is.
Caddy Routes
You'll also need to tell Caddy to forward websocket requests to the AnyCable process. You can modify the Caddy routes for your app to look like the following.
# Intercept websocket requests and forward to AnyCable
reverse_proxy /cable localhost:8080
# Handle other requests as normal
%{default}
Make sure that the 8080 port number matches the ANYCABLE_PORT environment variable.