You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: other-guides/heroku.md
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ In your package.json, add the following section \(changing node to the right ver
32
32
33
33
```javascript
34
34
"engines": {
35
-
"node":"8.x",
35
+
"node":"10.x",
36
36
"npm":"*"
37
37
},
38
38
```
@@ -52,10 +52,11 @@ Save the file, you're done with it for the moment.
52
52
53
53
Next, you need a thing called a `Procfile`. This tells Heroku exactly how to run your project, specifically it says that it should _not_ expect an HTTP server to be started. If this isn't done, Heroku will stop your project after a couple minutes because it failed to bind an http server to the appropriate port.
54
54
55
-
Create a new file called `Procfile` in your project \(no extension, with the uppercase P\), and add in the following contents:
55
+
Create a new file called `Procfile` in your project \(no extension, with the uppercase P\), and add in the following contents, which disables the need for a web server and lets your bot run:
56
56
57
57
```text
58
-
worker: npm start
58
+
web: echo "I don't want a web process"
59
+
service: npm start
59
60
```
60
61
61
62
## Creating the main bot file
@@ -114,35 +115,39 @@ To install the CLI just go right ahead and run `npm i -g heroku`. It'll take a f
114
115
115
116
Next, you need to login. From your prompt, go ahead and run `heroku login`. This will ask you to enter your email, and password, for Heroku.
116
117
117
-
Then finally, you need to create an _application_ on Heroku, if you haven't already done that on the website. So in my case, I just went `heroku create eviebot` and that took care of that! Oh make sure you run this _in your project folder_.
118
+
Then finally, you need to create an _application_ on Heroku. Go to your Dashboard, into [Create New App](https://dashboard.heroku.com/new-app). Enter a unique app name, like `my-super-original-bot`\(hereafter referred as <appname>\), in your closest region.
118
119
119
-
Woop woop! Almost there! One last thing before put in the last puzzle pieces, which is to configure the same Environment Variables that we have in our `.env` file. Go right ahead and visit your dashboard, which would be the following URL: `https://dashboard.heroku.com/apps/<appname>/settings`\(replace `<appname>` with the one you just created, of course\). It should look like this:
120
+
One last thing before put in the last puzzle pieces, which is to configure the same Environment Variables that we have in our `.env` file. In the app's dashboard, go to the Settings tab, then click Reveal Config Vars. Add the 2 configuration variables. It should look like this:
Let's pre-emptively open up the logs so we can see what's going on on the server:
125
+
126
+
In your app's dashboard, click the "More" button at the top-right:
127
+
128
+

129
+
130
+
It'll be empty for now, don't worry, let's keep going!
131
+
123
132
## Pushing the app
124
133
125
134
So we're on the last mile now! Everything you've done until now has prepared us for this moment.
126
135
127
136
*`git init` make our project git-enabled.
128
-
*`heroku create <appname>` generated a link to your heroku project.
129
137
*`npm init -y` and the package.json file modifications prepared our project for the Heroku universe.
130
138
131
139
So let's finalize everything by saving our changes to `git` and pushing them to Heroku:
132
140
133
141
* Add all the files to git with `git add .`\(don't forget the dot!\)
134
142
* Prepare for pushing using commit: `git commit -m "Initial bot commit for Heroku"`
135
143
* Push the entire thing to Heroku: `git push heroku master`
144
+
* You'll see quite a lot of output logs which should end with something like "Verifying deploy... done."
136
145
137
146
OMG. That's... it. can you believe it? Your bot's now on Heroku and should really be running already!
138
147
139
-
To verify, look at the logs, from the top-right "More" button:
140
-
141
-

142
-
143
-
It should look like this:
148
+
Take a look at the logs on the dashboard, It should look like this \(Note: You'll have a few lines about processes crashing with Error Code 0, those are normal\):
And we're done! This should be enough to get you going, remember Heroku can't do a whole lot of processing, and you can't save files \(no file database, edited json, etc\).
0 commit comments