Comments (8)
In Rails you can start the server the same way in config.ru
. If you look at the implementation of start_from_database!
, it ends up calling start_async which doesn't block.
from slack-ruby-bot.
Share some more code if you can't get it to work! I'll close this for now.
from slack-ruby-bot.
Thanks for reply!
I could start slack-ruby-bot on Rails with config.ru
!
If possible I want to manage separately Rails and slack-ruby-bot, but below codes didn't work. Do you have any idea?
Thanks
Gemfile
gem 'slack-ruby-bot', '~> 0.8.0'
gem 'celluloid-io', require: ['celluloid/current', 'celluloid/io']
Procfile
slack_server: bundle exec rails runner bin/slack_server
web: bundle exec rails server
bin/slack_server
SlackBotServer::App.instance.prepare!
Thread.abort_on_exception = true
Thread.new do
SlacklBotServer::Service.start_from_database!
end
lib/slack-bot-server/app.rb
same as https://github.com/dblock/slack-bot-server/blob/master/slack-bot-server/app.rb
lib/slack-bot-server/service.rb
same as https://github.com/dblock/slack-bot-server/blob/master/slack-bot-server/service.rb
lib/slack-bot-server/server.rb
same as https://github.com/dblock/slack-bot-server/blob/master/slack-bot-server/server.rb
from slack-ruby-bot.
Define "doesn't work"?
Generally if you want your rails app to be also the registration for teams you're going to need a mechanism of telling the bot that a new team has been registered (they run in separate processes).
from slack-ruby-bot.
If the problem is bundle exec rails runner bin/slack_server
, try bundle exec ruby bin/slack_server
from slack-ruby-bot.
Thanks again for your reply!
Define "doesn't work"?
Sorry for not explaining enough. I mean it doesn't start, throwing no error.
➜ testbot git:(master) ✗ bundle exec rails runner bin/slack_server.rb
I, [2016-05-25T11:10:28.532585 #10687] INFO -- : Starting team #<Team:0x007feeaa789fb0>.
I, [2016-05-25T11:10:28.564831 #10687] INFO -- : post https://slack.com/api/rtm.start
D, [2016-05-25T11:10:28.564899 #10687] DEBUG -- request: Accept: "application/json; charset=utf-8"
User-Agent: "Slack Ruby Client/0.7.3"
Content-Type: "application/x-www-form-urlencoded"
➜ testbot git:(master) ✗
So I tried to comment out Thread.new
block and call bundle exec rails runner bin/slack_server.rb
, got messages below;
# bin/slack_server.rb
SlackBotServer::App.instance.prepare!
# Thread.abort_on_exception = true
# Thread.new do
SlacklBotServer::Service.start_from_database!
# end
➜ testbot git:(master) ✗ bundle exec rails runner bin/slack_server.rb
I, [2016-05-25T10:43:02.193632 #9548] INFO -- : Starting team #<Team:0x007f9aaaa0e230>.
I, [2016-05-25T10:43:02.235586 #9548] INFO -- : post https://slack.com/api/rtm.start
D, [2016-05-25T10:43:02.235661 #9548] DEBUG -- request: Accept: "application/json; charset=utf-8"
User-Agent: "Slack Ruby Client/0.7.3"
Content-Type: "application/x-www-form-urlencoded"
I, [2016-05-25T10:43:03.218362 #9548] INFO -- Status: 200
D, [2016-05-25T10:43:03.218459 #9548] DEBUG -- response: content-type: "application/json; charset=utf-8"
transfer-encoding: "chunked"
connection: "close"
access-control-allow-origin: "*"
cache-control: "private, no-cache, no-store, must-revalidate"
content-security-policy: "referrer no-referrer;"
date: "Wed, 25 May 2016 01:43:02 GMT"
expires: "Mon, 26 Jul 1997 05:00:00 GMT"
pragma: "no-cache"
server: "Apache"
strict-transport-security: "max-age=31536000; includeSubDomains; preload"
vary: "Accept-Encoding"
x-accepted-oauth-scopes: "rtm:stream,client"
x-content-type-options: "nosniff"
x-oauth-scopes: "identify,bot:basic"
x-xss-protection: "0"
x-cache: "Miss from cloudfront"
via: "1.1 f960dafcb3c8e2a2fc983a4e6653ee56.cloudfront.net (CloudFront)"
x-amz-cf-id: "8sf-oAkSs55E6a3ns878rZ1XeEFry3Fh_dLegM7TVhNtOCBkeaDCXg=="
D, [2016-05-25T10:43:03.233625 #9548] DEBUG -- Slack::RealTime::Concurrency::Celluloid::Socket#connect!: WebSocket::Driver::Client
➜ testbot git:(master) ✗
If the problem is bundle exec rails runner bin/slack_server, try bundle exec ruby bin/slack_server
It depends on ActiveRecord for this, I need to exec with rails runner...
Thank you
from slack-ruby-bot.
Your program just terminates, it doesn't block on anything and by its end a bunch of connections are being opened while it exits. All this starts asynchronously, something has to block forever. In a mixed example with Rails you have a web server waiting for connections, and in your you want this:
loop do
Thread.pass
end
from slack-ruby-bot.
It works! ✨
Thank you for taking the time! 🙏
from slack-ruby-bot.
Related Issues (20)
- Getting lots of 429 rate limit errors on https://slack.com/api/rtm.start calls HOT 7
- Graceful shutdown HOT 1
- Testing other code execution inside a command HOT 8
- Deployment tutorial needs update HOT 2
- DMing self produces Sorry @Slackbot, I don't understand that command! HOT 1
- Migration to non-legacy bots HOT 6
- Consider splitting RSpec shared behaviours and development dependencies HOT 4
- Where can i find more info on the client.say method? HOT 7
- Remove support for Giphy
- Extract attachments text
- without mention in channel bot can't reply HOT 1
- Upload a file? HOT 1
- Pongbot does not run on linux mint 19 HOT 4
- Testing for two outputs from a command HOT 5
- When a command is posted in thread, its again posted as direct message automatically HOT 4
- is there an example for how to implement a conversational bot using slack-ruby-bot? HOT 1
- Missing concurrency - Add faye-websocket to your gemfile -- It's already in my Gemfile HOT 1
- Clarification of MIGRATION.md HOT 8
- Is this repo really legacy, there is still a use case? HOT 3
- Repeated 429 (ratelimited) errors from slack HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slack-ruby-bot.