I have a script which uses a gem that has eventmachine
which listens for an API call (it's the slack-api gem).
On my dev environment, I just run bundle exec ruby ruby_slack.rb
and the console shows that it is listening. When the API call hits, then I see the stdout
.
How do I have this same behavior in heroku?
I created a Procfile
which has: web: bundle exec ruby slack.rb
but I think it's just waiting for a request from the web app to run it.
I want this to run (and keep running) listening for events.
Thanks.
You need a web server that responds on the port that Heroku asks it to respond and a thread for websocket processing. For example with Sinatra:
This is captured in this tutorial. Also generally try slack-ruby-bot which does all the heavy lifting for you.