Deploying the Template Engine

Follow the commands to deploy to Heroku:

  1. Change directory, cd, into the engine directory into your local machine where you have the engine working. Recall that we have chosen the engine from the Ecommerce Recommender template.
  2. Initialize git init:
git init
  1. Create a Heroku app from the following piece of code:
heroku create recommenderapp
heroku buildpacks:add -i 1
https://github.com/heroku/heroku-buildpack-jvm-common.git

heroku buildpacks:add -i 2
https://github.com/heroku/predictionio-buildpack.git
  1. Configure the Heroku app to use eventserver:
heroku addons:attach $POSTGRES_ADDON_ID

# Generate a random key.
export ACCESS_KEY="$RANDOM-$RANDOM-$RANDOM-$RANDOM"

heroku config:set
PIO_EVENTSERVER_HOSTNAME=$EVENTSERVER_NAME.herokuapp.com
PIO_EVENTSERVER_PORT=80
PIO_EVENTSERVER_ACCESS_KEY=$ACCESS_KEY
PIO_EVENTSERVER_APP_NAME=$PIO_APP_NAME #
must match `appName` in engine.json
$POSTGRES_ADDON_ID is the ID you can obtain from your postgresql that was created earlier. Check the following screenshot for the same. $EVENTSERVER_NAME is the eventserver Heroku app that was created earlier:
  1. The first time an engine is deployed, it requires data for training. For example, engines containing data/initial-events.json; this data will automatically be imported into eventserver before training. So, make sure your project Data folder has a file named initial-events.json for the sample data.
For Production apps, you might want to custom code a data loader script or customize the engine's DataSource.scala to use a preexisting data store instead of eventserver.
  1. Deploy the app to Heroku using the following commands:
git add .
git commit -m "Initial PIO engine"
git push heroku master

Note that the initial deployment will probably fail due to memory constraints.

The error would read something like the following, and you will need to scale the memory with paid dyno. Note that you will be charged, so you may want to skip it if you are building the app as a hobby or for experimentation.

The memory error with single free dyno would display in Heroku, as shown in the following screenshot:

However, if you want to scale the memory, you can use the following code snippet on your CLI to scale up (note that you will be charged for scaling):

  heroku ps:scale 
web=1:Performance-M
release=0:Performance-L
train=0:Performance-L
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset