Skip to content
This repository has been archived by the owner on Jun 25, 2018. It is now read-only.

on_startup doesn't seem to happen ever... #71

Closed
davidcelis opened this issue Jan 19, 2015 · 4 comments
Closed

on_startup doesn't seem to happen ever... #71

davidcelis opened this issue Jan 19, 2015 · 4 comments

Comments

@davidcelis
Copy link

Hey; I'm on the latest version of twitter_ebooks. I have my bot running on Heroku, and it doesn't seem to be tweeting. My on_startup usually looks like this:

def on_startup
  #10% chance to make a tweet in any hour
  if rand > 0.9
    tweet(model.make_statement)
  end
end

My bot hasn't written its own tweet in almost two weeks. This started right about the time I upgraded to the latest major version of twitter_ebooks. To debug, I removed the conditional statement. So, after deploys, my bot should be immediately tweeting. But it isn't. A quick call of heroku logs also shows no errors. Only that my bot is streaming tweets. This makes me think there might be something up with the on_startup method... Any thoughts?

@davidcelis
Copy link
Author

Oh! I should mention that if I do heroku run irb, load my bot, and call bot.tweet(bot.model.make_statement) manually, it'll post a tweet like usual.

@negatendo
Copy link
Contributor

This would cause the bot to have a chance of tweeting once on startup. If you want the bot to tweet regularly you'll want a separate section in the behaviors to define that schedule. See the ebooks example: https://github.com/mispy/ebooks_example

On Jan 18, 2015, at 10:57 PM, David Celis notifications@github.com wrote:

Hey; I'm on the latest version of twitter_ebooks. I have my bot running on Heroku, and it doesn't seem to be tweeting. My on_startup usually looks like this:

def on_startup

90% chance to make a tweet in any hour

if rand > 0.9
tweet(model.make_statement)
end
end
My bot hasn't written its own tweet in almost two weeks. This started right about the time I upgraded to the latest major version of twitter_ebooks. To debug, I removed the conditional statement. So, after deploys, my bot should be immediately tweeting. But it isn't. A quick call of heroku logs also shows no errors. Only that my bot is streaming tweets. This makes me think there might be something up with the on_startup method... Any thoughts?


Reply to this email directly or view it on GitHub.

@davidcelis
Copy link
Author

Sorry! That was a mistake in my example... I should have just copied and pasted:

def on_startup
  # 10% chance to tweet something in any 60 minute interval
  scheduler.every '1h' do
    if rand > 0.90
      tweet(model.make_statement)
    end
  end
end

For my test I removed both the scheduler and if conditional, expecting it to make a tweet on startup, but it doesn't. So, to clarify... The following does not produce a tweet on startup like would be expected:

def on_startup
  tweet(model.make_statement)
end

@davidcelis
Copy link
Author

I found the issue. on_startup is fired by calling prepare on the bot, which I wasn't doing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants