Skip to content

add instructions to deploy to heroku #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,47 @@ In order to test I would:
10. Choose **Save and test**.
11. Upon successful execution, view results in the console.
![Imgur](http://i.imgur.com/TV2E1LO.png)

### Using in Heroku

The following instructions will set up the node process to run every day at a specific time using [Heroku](https://www.heroku.com/home)

#### Prerequisits

1. You need to [sign up](https://signup.heroku.com/) for an Heroku account or use an existing one.
2. You will also need to [add a credit card](https://dashboard.heroku.com/account/billing) as the scheduler can't be added without one (100 hours are free per month) but you won't be charged for one run per day.

#### Deploy the app

Install the heroku cli

```shell
npm install heroku-cli
```

Create a new app, add a scheduler and deploy the code by running the npm script heroku

```shell
npm run heroku
```

* You will be asked for your heroku username and password
* The scheduler dashboard should open automatically

1. Presss the ```Create job``` button
2. Set the FREQUENCY to ```Daily```
3. In the "$" text box write ```node server.js```
4. Press the ```save``` button

![Imgr](http://i.imgur.com/1Y5s7aQ.gif)

#### Add environment variables

Set the environment variables to give you packt email login and password

Replace ```your-email-here``` and ```your-password-here``` with your own details

```shell
heroku config:set PACKT_EMAIL=your-email-here
heroku config:set PACKT_EMAIL=your-password-here
```
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
"version": "0.0.0",
"description": "grabbing a book a day",
"main": "server.js",
"scripts": {
"heroku": "npm-run-all heroku:*",
"heroku:login": "heroku login",
"heroku:create-app": "heroku create",
"heroku:create-scheduler": "heroku addons:create scheduler:standard",
"heroku:open-dashboard": "heroku addons:open scheduler",
"heroku:deploy": "git push heroku master"
},
"repository": "",
"author": "",
"dependencies": {
"cheerio": "latest",
"dotenv": "^1.1.0",
"request": "latest"
},
"devDependencies": {
"npm-run-all": "^4.0.2"
}
}