Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Installing on Heroku

Tim Malone edited this page Jun 21, 2017 · 15 revisions

First up, click this button!

Deploy to Heroku

Sign in/up to Heroku if you need to, and follow the instructions on screen.

Note that you'll also need an AWS account, because we'll need to store assets on S3. You'll be asked for your AWS access details during the Heroku set up process, including the name of two existing S3 buckets: one for public read access of image assets, and another for private access for game data storage.

You'll also be asked for access details to your Slack organisation. To get the Slack side of things set up, follow the main instructions in the README. The environment variables step is already taken care of for you during the Heroku set up, but everything else needs to be done.

You now need to set up cron, as discussed in the README. Probably the simplest method of doing this at the moment is to use an external service such as cron-job.org (Heroku does offer a scheduler, but it doesn't have the granularity that Slackémon needs at present).

Create an account on cron-job.org, and set up a cron for every minute to call your Heroku server like this:

https://your-app-name.herokuapp.com/cron.php?token=XXXXXXXXXXXXXXXXXXXX

In the URL above, you'll need to replace the token with the value of the SLACKEMON_CRON_TOKEN environment variable that was set up when you installed the app (you can find it under the Settings tab of your app, after clicking Reveal Config Vars). This token prevents people from stumbling across and invoking the cron script unauthorised.

If you've followed all these steps, including the normal Slack setup steps in the README, it's time to start playing!
You should now be able to run /slackemon anywhere in your Slack team to start the quick player onboarding process 👍 .

Things to keep in mind

  • Due to the cron running every minute, your Heroku dyno will always be active, even when you or others on your Slack organisation aren't using Slackémon. There are enough hours on a verified free Heroku plan to keep Slackémon running 24/7, as long as you don't have any other apps using up those hours. You can limit your cron when setting it up to only run during waking hours if you want to curb this a little, however with the present version of Slackémon this can cause issues if people are battling while the cron isn't running. A future version of Slackémon will make this easier.

  • Slackémon is still very much in alpha. It is recommended to keep an eye on PHP errors generated by the app while it is running. In your Heroku dashboard, you'll see that Slackémon has been set up with the Papertrail addon. Papertrail is an excellent log aggregator and it works out of the box with Heroku. You'll probably find it helpful to be alerted automatically of errors on Slack: within Papertrail, from the search box, enter program:app/web.1 ("PHP Fatal error:" OR "PHP Warning:" OR "PHP Notice:" OR "PHP Log:"), then click Save Search. Follow the prompts to set up an alert for the search - Slack is one of the options.

  • Postgres is recommended as your data store (not data cache), and is the default for Slackémon when installing on Heroku. You can use AWS or store locally, but these are not recommended due to S3's eventually consistent filesystem and Heroku's ephemeral filesystem.

Todo's

  • The S3 buckets could probably be created automatically via the AWS API

  • We should add optional steps for setting up automatic updates (redeployments) from GitHub every time a new version of Slackémon is released.


Running with heroku local

If you have the Heroku CLI or the Ruby Foreman gem installed, you can also try running Slackémon locally:

git clone https://github.com/tdmalone/slackemon.git
cd slackemon
heroku local # OR foreman start

You may need to run sudo heroku local / sudo foreman start instead, and there may be other dependencies you need to install on your system - follow the errors if required!

Once you're done, you should be able to access a local server at http://localhost:5000. If you get permission errors relating to /tmp/heroku.fcgi.5000.sock, open a new shell and run:

sudo chmod 0667 /tmp/heroku.fcgi.5000.sock

(Thanks to Andrew Berezovskyi for the tip).

This is not an officially support method of running Slackémon, yet. But it is included here for completeness.