I am working on trying to integrate some slack commands that can interact with my Rails application. Awhile back, I was leveraging Sidekiq for this, but then I realized that this might not be a good idea.
I'm using the following Gems to accomplish this currently:
# Slack-ruby-client
gem "eventmachine"
gem "async-websocket", "~> 0.8.0"
gem "rails_best_practices"
gem "slack-ruby-client"
gem "websocket-driver"
When the worker would usually execute, it would run the following:
def monitor
@client.on :hello do
@messenger.send_message("Bot is now connected!")
end
@client.on :message do |data|
case data.text
when /!help/
... etc
However, I feel like this isn't a good practice. From time to time, the worker would run twice (if it's been running for a few days, it may restart itself for some reason). Is there a better way to do this in Rails?