diff --git a/.gitignore b/.gitignore index 5c514e8..310459a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ yarn-debug.log* /app/assets/builds/* !/app/assets/builds/.keep + +bin/dist diff --git a/Procfile.dev b/Procfile.dev index cb99e31..42284b3 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ server: bundle exec rails s -p 3000 css: yarn build:css --watch js: yarn build --watch -ws: anycable-go --port=8080 --broadcast_adapter=http +ws: bin/anycable-go --port=8080 --broadcast_adapter=http --presets=broker --rpc_host=http://localhost:3000/_anycable diff --git a/README.md b/README.md index fd39e80..132143b 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,10 @@ bin/setup ## Running -You can start Rails server by running: +Since you need to run multiple processes (Rails, AnyCable-Go), we recommend using a process manager, e.g., [Hivemind](https://github.com/DarthSim/hivemind): ```sh -bundle exec rails s +hivemind Procfile.dev ``` Then go to [http://localhost:3000/](http://localhost:3000/) and see the application in action. diff --git a/bin/anycable-go b/bin/anycable-go new file mode 100755 index 0000000..6e167a4 --- /dev/null +++ b/bin/anycable-go @@ -0,0 +1,19 @@ +#!/bin/bash + +cd $(dirname $0)/.. + +version="1.5.0" + +if [ ! -f ./bin/dist/anycable-go ]; then + echo "AnyCable-go is not installed, downloading..." + ./bin/rails g anycable:download --version=$version --bin-path=./bin/dist +fi + +curVersion=$(./bin/dist/anycable-go -v) + +if [[ "$curVersion" != "$version"* ]]; then + echo "AnyCable-go version is not $version, downloading a new one..." + ./bin/rails g anycable:download --version=$version --bin-path=./bin/dist +fi + +./bin/dist/anycable-go $@