arunthampi / relax

Bots-as-a-Service for Slack
Mozilla Public License 2.0
169 stars 23 forks source link

Problem getting relax to work on heroku #13

Closed onlymejosh closed 8 years ago

onlymejosh commented 8 years ago

Hey there,

I came across relax last night and am really excited to be using it! I was actually planning on building my own with a very similar architecture until I came across relax!

I've fallen over at the first hurdle though. I used the deploy to heroku button adding my team and bot to redis. My bot however is still offline, have I missed something?

2016-03-16T15:05:43+00:00 app[heroku-redis]: source=REDIS sample#active-connections=3 sample#load-avg-1m=0.14 sample#load-avg-5m=0.15 sample#load-avg-15m=0.2 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15666160.0kB sample#memory-free=13426948.0kB sample#memory-cached=534480kB sample#memory-redis=338832bytes sample#hit-rate=0.25 sample#evicted-keys=0
2016-03-16T14:22:43.948112+00:00 heroku[web.1]: Idling
2016-03-16T14:22:43.948883+00:00 heroku[web.1]: State changed from up to down
2016-03-16T14:22:47.611025+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-03-16T14:22:48.540290+00:00 app[web.1]: 2016/03/16 14:22:48 Exiting pid 3.
2016-03-16T14:22:48.540374+00:00 app[web.1]: time="2016-03-16T14:22:48Z" level=info msg="relax: started healthcheck server on 0.0.0.0:49446"
2016-03-16T14:22:48.540397+00:00 app[web.1]: time="2016-03-16T14:22:48Z" level=info msg="relax: healthcheck server stopped"
2016-03-16T14:22:49.302020+00:00 heroku[web.1]: Process exited with status 0
2016-03-16T14:23:22+00:00 app[heroku-redis]: source=REDIS sample#active-connections=2 sample#load-avg-1m=0.35 sample#load-avg-5m=0.275 sample#load-avg-15m=0.515 sample#read-iops=0 sample#write-iops=0.014113 sample#memory-total=15666160.0kB sample#memory-free=13423524.0kB sample#memory-cached=534284kB sample#memory-redis=317832bytes sample#hit-rate=0.25 sample#evicted-keys=0
2016-03-16T14:24:17+00:00 app[heroku-redis]: source=REDIS sample#active-co

I'm seeing this in the logs if that helps

arunthampi commented 8 years ago

Hey @onlymejosh my github notifications are wonky and I don't get these notifications -- trying to figure out why.

I haven't tried out the "Deploy to Heroku" button in a while, let me test it out and see if there's anything wrong. Can you please paste the output for heroku ps in the meanwhile?

onlymejosh commented 8 years ago

Hey @arunthampi no problem! I was actually going to email you as I see you offer hosting too? I'd like to chat about relax as I have a few questions too :)

Free quota left: 18h 0m
=== web (Free): relax (1)
web.1: up 2016/03/22 21:35:14 +0000 (~ 3s ago)

This is what I see in the logs:

2016-03-22T21:35:10.116088+00:00 heroku[web.1]: State changed from down to starting
2016-03-22T21:35:10.650228+00:00 heroku[web.1]: Starting process with command `relax`
2016-03-22T21:35:12.450842+00:00 app[web.1]: time="2016-03-22T21:35:12Z" level=info msg="connected to redis host" host="ec2-107-22-214-1.compute-1.amazonaws.com:18969" result=PONG
2016-03-22T21:35:12.452633+00:00 app[web.1]: 2016/03/22 21:35:12 Serving [::]:40472 with pid 3
2016-03-22T21:35:14.278951+00:00 heroku[web.1]: State changed from starting to up
2016-03-22T21:35:15.205868+00:00 heroku[router]: at=info method=GET path="/" host=lea-slack-controller.herokuapp.com request_id=5d104165-99b8-47af-a567-70106845e9bf fwd="86.181.145.20" dyno=web.1 connect=1ms service=2ms status=200 bytes=148
2016-03-22T21:35:15.448161+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=lea-slack-controller.herokuapp.com request_id=e583ceb0-071b-4a7a-b0de-b3e1ba2d12f8 fwd="86.181.145.20" dyno=web.1 connect=1ms service=2ms status=200 bytes=148
WARNING: Toolbelt v3.42.44 update available.

But I'm not seeing my bot online

arunthampi commented 8 years ago

Just checking did you start a bot with the Ruby client? https://github.com/zerobotlabs/relax-rb

arunthampi commented 8 years ago

and you can email me at arun@zerobotlabs.com for hosting questions :)

onlymejosh commented 8 years ago

I didn’t I’m not going to be use ruby. I followed the guide on the relax README and ran

PUBLISH redis_bots_pubsub ' {"type":"team_added","team_id":"TDEADBEEF”}

arunthampi commented 8 years ago

did you also HSET with team_id and bot_token? https://github.com/zerobotlabs/relax/#starting-bots

onlymejosh commented 8 years ago

Yep heres my output

ec2-107-22-214-1.compute-1.amazonaws.com:18969> MULTI
OK
ec2-107-22-214-1.compute-1.amazonaws.com:18969> HSET redis_bots_key U03RK4N0A '{"team_id":"U03RK4N0A","token":"xoxp-MY-TOKEN"}'
QUEUED
ec2-107-22-214-1.compute-1.amazonaws.com:18969> HGETALL redis_bots_key
QUEUED
ec2-107-22-214-1.compute-1.amazonaws.com:18969> PUBLISH redis_bots_pubsub '{"type":"team_added","team_id":"U03RK4N0A"}'
QUEUED
ec2-107-22-214-1.compute-1.amazonaws.com:18969> EXEC
1) 1
2) T03RK4MV2,{"team_id":"T03RK4MV2", "token":"xoxb-26058478530-WZiSAiIljzkZvrvnC7hpmMXi"},U03RK4N0A,{"team_id":"U03RK4N0A","token":"xoxp-MY-TOKEN"}
3) 0
ec2-107-22-214-1.compute-1.amazonaws.com:18969>
arunthampi commented 8 years ago

I'm starting up a fresh relax install on Heroku to see what's going on, but in the mean time -- are you sure the team_id's are correct? the U03RK4N0A ID looks like a user Id and not a team id.

onlymejosh commented 8 years ago

You re correct! it wasn't a team id. I replaced it with the correct key and still no luck

arunthampi commented 8 years ago

looks like there was a typo in the documentatin which I fixed here! https://github.com/zerobotlabs/relax/commit/c7476d4b741c8b1d2966f5199ae5cc1769e2b491

By default the keys in Redis that you need to manipulate are relax_bots_key and relax_bots_pubsub and not redis_bots_key and redis_bots_pubsub. I've made those changes to the documentation. Thanks for catching it and let me know if that works.

arunthampi commented 8 years ago

also just curious -- what language do you intend to write your relax client in? would love to fill that gap. I have a todo for a node client

onlymejosh commented 8 years ago

Awesome! Seems to be working now! I should of looked at the key names instead of blindly copying and pasting.

So I'm actually using botkit at the moment but am not happy with it. I'm generally a ruby developer but I want to use node so the library would be great!

I checked out relax-rb and it looks like you post messages to the relax pubsub. https://github.com/zerobotlabs/relax-rb/blob/master/lib/relax/bot.rb#L38 How does this work?

I really like the use of redis for queues it seems like the best way to handle messages in and out. Have you thought about handling conversations?

arunthampi commented 8 years ago

I checked out relax-rb and it looks like you post messages to the relax pubsub. https://github.com/zerobotlabs/relax-rb/blob/master/lib/relax/bot.rb#L38 How does this work?

Because you can run multiple instances of Relax (on multiple dynos for e.g.) and it should act like one instance of Relax, i use pubsub so that all instances get messages. There's a pubsub listener on relax that listens on the pubsub channel.

I really like the use of redis for queues it seems like the best way to handle messages in and out.

Haha funny you mention it, I was thinking of a different protocol (for e.g. websockets)

Have you thought about handling conversations?

I have, but I think it might be outside the scope of relax. I think this should be handled by the app, but if there ways I can make that easier, I'm open to suggestions.

Thanks for your feedback! Closing the issue for now, open new ones if you run into other issues or email me.

arunthampi commented 8 years ago

closed by https://github.com/zerobotlabs/relax/commit/c7476d4b741c8b1d2966f5199ae5cc1769e2b491