rundoc 1.0.0 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/check_changelog.yml +13 -0
- data/.gitignore +7 -0
- data/CHANGELOG.md +27 -0
- data/Dockerfile +24 -0
- data/README.md +221 -100
- data/bin/rundoc +4 -68
- data/lib/rundoc.rb +1 -0
- data/lib/rundoc/cli.rb +84 -0
- data/lib/rundoc/code_command.rb +3 -2
- data/lib/rundoc/code_command/background/process_spawn.rb +30 -4
- data/lib/rundoc/code_command/background/start.rb +2 -0
- data/lib/rundoc/code_command/bash.rb +3 -2
- data/lib/rundoc/code_command/bash/cd.rb +20 -2
- data/lib/rundoc/code_command/no_such_command.rb +4 -0
- data/lib/rundoc/code_command/pipe.rb +17 -4
- data/lib/rundoc/code_command/rundoc/depend_on.rb +37 -0
- data/lib/rundoc/code_command/rundoc/require.rb +41 -0
- data/lib/rundoc/code_command/rundoc_command.rb +4 -1
- data/lib/rundoc/code_command/website.rb +7 -0
- data/lib/rundoc/code_command/website/driver.rb +111 -0
- data/lib/rundoc/code_command/website/navigate.rb +29 -0
- data/lib/rundoc/code_command/website/screenshot.rb +28 -0
- data/lib/rundoc/code_command/website/visit.rb +47 -0
- data/lib/rundoc/code_section.rb +13 -4
- data/lib/rundoc/parser.rb +4 -3
- data/lib/rundoc/peg_parser.rb +1 -1
- data/lib/rundoc/version.rb +1 -1
- data/rundoc.gemspec +7 -2
- data/test/fixtures/build_logs/rundoc.md +56 -0
- data/test/fixtures/depend_on/dependency/rundoc.md +5 -0
- data/test/fixtures/depend_on/main/rundoc.md +10 -0
- data/test/fixtures/java/rundoc.md +9 -0
- data/test/fixtures/rails_4/rundoc.md +8 -5
- data/test/fixtures/rails_5/rundoc.md +17 -7
- data/test/fixtures/{rails_5_beta → rails_6}/rundoc.md +97 -88
- data/test/fixtures/require/dependency/rundoc.md +5 -0
- data/test/fixtures/require/main/rundoc.md +10 -0
- data/test/fixtures/screenshot/rundoc.md +10 -0
- data/test/rundoc/code_commands/background_test.rb +26 -0
- data/test/rundoc/code_commands/bash_test.rb +7 -0
- data/test/rundoc/code_commands/pipe_test.rb +11 -1
- data/test/rundoc/parser_test.rb +0 -1
- data/test/rundoc/peg_parser_test.rb +43 -0
- metadata +90 -11
@@ -9,7 +9,7 @@ end
|
|
9
9
|
```
|
10
10
|
<!--
|
11
11
|
rundoc src:
|
12
|
-
https://github.com/schneems/rundoc/blob/
|
12
|
+
https://github.com/schneems/rundoc/blob/main/test/fixtures/rails_5/rundoc.md
|
13
13
|
|
14
14
|
Command:
|
15
15
|
$ bin/rundoc build --path test/fixtures/rails_5/rundoc.md
|
@@ -18,7 +18,7 @@ end
|
|
18
18
|
Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails 5 on Heroku. For information on running previous versions of Rails on Heroku, see the tutorial for [Rails 4.x](getting-started-with-rails4) or [Rails 3.x](getting-started-with-rails3).
|
19
19
|
|
20
20
|
```
|
21
|
-
:::-- $ ruby -e "exit 1 unless RUBY_VERSION == '2.
|
21
|
+
:::-- $ ruby -e "exit 1 unless RUBY_VERSION == '2.6.3'"
|
22
22
|
```
|
23
23
|
|
24
24
|
For this guide you will need:
|
@@ -53,7 +53,7 @@ If you are starting with an existing app that uses a previous version of Rails,
|
|
53
53
|
To create a new app, first make sure that you're using Rails 5.x by running `rails -v`. If necessary, you can get the new version of rails by running the following:
|
54
54
|
|
55
55
|
```term
|
56
|
-
:::>> $ gem install rails --no-
|
56
|
+
:::>> $ gem install rails --no-document
|
57
57
|
```
|
58
58
|
|
59
59
|
Then create a new app and move into its root directory:
|
@@ -68,6 +68,12 @@ Then move into your application directory.
|
|
68
68
|
:::>- $ cd myapp
|
69
69
|
```
|
70
70
|
|
71
|
+
Create a database locally:
|
72
|
+
|
73
|
+
```
|
74
|
+
:::>> $ bin/rake db:create
|
75
|
+
```
|
76
|
+
|
71
77
|
## Add the pg gem
|
72
78
|
|
73
79
|
If you're using an existing app that was created without specifying `--database=postgresql`, you need to add the `pg` gem to your Rails project. Edit your `Gemfile` and change this line:
|
@@ -158,7 +164,7 @@ Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby instal
|
|
158
164
|
```ruby
|
159
165
|
:::-- $ sed -i'' -e '/^ruby/d' ./Gemfile
|
160
166
|
:::-> file.append Gemfile#4
|
161
|
-
ruby "2.
|
167
|
+
ruby "2.6.3"
|
162
168
|
```
|
163
169
|
|
164
170
|
You should also be running the same version of Ruby locally. You can check this by running `$ ruby -v`. You can get more information on [specifying your Ruby version on Heroku here](https://devcenter.heroku.com/articles/ruby-versions).
|
@@ -209,15 +215,19 @@ Make sure you are in the directory that contains your Rails app, then create an
|
|
209
215
|
You can verify that the remote was added to your project by running:
|
210
216
|
|
211
217
|
```term
|
212
|
-
:::>> $ git config --list | grep heroku
|
218
|
+
:::>> $ git config --list --local | grep heroku
|
213
219
|
```
|
214
220
|
|
215
221
|
If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise you can deploy your code. After you deploy your code, you need to migrate your database, make sure it is properly scaled, and use logs to debug any issues that come up.
|
216
222
|
|
223
|
+
|
224
|
+
>note
|
225
|
+
>Following changes in the industry, Heroku has updated our default git branch name to `main`. If the project you’re deploying uses `master` as its default branch name, use `git push heroku master`.
|
226
|
+
|
217
227
|
Deploy your code:
|
218
228
|
|
219
229
|
```term
|
220
|
-
:::>> $ git push heroku
|
230
|
+
:::>> $ git push heroku main
|
221
231
|
```
|
222
232
|
|
223
233
|
It is always a good idea to check to see if there are any warnings or errors in the output. If everything went well you can migrate your database.
|
@@ -364,7 +374,7 @@ Looks good, so press `Ctrl+C` to exit and you can deploy your changes to Heroku:
|
|
364
374
|
```term
|
365
375
|
:::>- $ git add .
|
366
376
|
:::>- $ git commit -m "use puma via procfile"
|
367
|
-
:::>- $ git push heroku
|
377
|
+
:::>- $ git push heroku main
|
368
378
|
```
|
369
379
|
|
370
380
|
Check `ps`. You'll see that the web process uses your new command specifying Puma as the web server.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
```
|
2
|
-
|
2
|
+
:::-- rundoc
|
3
3
|
email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
|
4
4
|
|
5
5
|
Rundoc.configure do |config|
|
@@ -7,32 +7,36 @@ Rundoc.configure do |config|
|
|
7
7
|
config.filter_sensitive(email => "developer@example.com")
|
8
8
|
end
|
9
9
|
```
|
10
|
+
|
10
11
|
<!--
|
11
12
|
rundoc src:
|
12
|
-
https://github.com/schneems/rundoc/blob/
|
13
|
+
https://github.com/schneems/rundoc/blob/main/test/fixtures/rails_6/rundoc.md
|
14
|
+
|
15
|
+
Command:
|
16
|
+
$ bin/rundoc build --path test/fixtures/rails_6/rundoc.md
|
13
17
|
-->
|
14
18
|
|
15
|
-
Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails
|
19
|
+
Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails 6 on Heroku. For information on running previous versions of Rails on Heroku, see the tutorial for [Rails 5.x](getting-started-with-rails5) or [Rails 4.x](getting-started-with-rails4).
|
20
|
+
|
21
|
+
```
|
22
|
+
:::-- $ ruby -e "exit 1 unless RUBY_VERSION == '2.6.6'"
|
23
|
+
```
|
16
24
|
|
17
25
|
For this guide you will need:
|
18
26
|
|
19
|
-
- Basic Ruby/Rails
|
20
|
-
- A locally installed version of Ruby 2.
|
21
|
-
- Basic Git knowledge.
|
27
|
+
- Basic familiarity with Ruby/Rails and Git
|
28
|
+
- A locally installed version of Ruby 2.5.0+, Rubygems, Bundler, and Rails 6+
|
22
29
|
- A Heroku user account: [Signup is free and instant](https://signup.heroku.com/devcenter).
|
23
30
|
|
24
|
-
## Local
|
25
|
-
|
26
|
-
Install the [Heroku Toolbelt](https://toolbelt.heroku.com/) on your local workstation. This ensures that you have access to the [Heroku command-line client](/categories/command-line), Heroku Local, and the Git revision control system. You will also need [Ruby and Rails installed](http://guides.railsgirls.com/install).
|
31
|
+
## Local setup
|
27
32
|
|
28
|
-
|
33
|
+
Install the [Heroku CLI](heroku-cli#download-and-install) on your development machine.
|
29
34
|
|
30
|
-
|
31
|
-
> callout Note that `$` symbol before commands indicates they should be run on the command line, prompt, or terminal with appropriate permissions. Do not copy the `$` symbol.
|
35
|
+
Once installed, the `heroku` command is available from your terminal. Log in using your Heroku account's email address and password:
|
32
36
|
|
33
37
|
```term
|
34
38
|
$ heroku login
|
35
|
-
Enter your Heroku credentials
|
39
|
+
heroku: Enter your Heroku credentials
|
36
40
|
Email: schneems@example.com
|
37
41
|
Password:
|
38
42
|
Could not find an existing public key.
|
@@ -41,41 +45,37 @@ Generating new SSH public key.
|
|
41
45
|
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
|
42
46
|
```
|
43
47
|
|
44
|
-
Press
|
45
|
-
|
46
|
-
## Write your app
|
47
|
-
|
48
|
-
> callout To run on Heroku, your app must be configured to use the Postgres database, have all dependencies declared in your `Gemfile`.
|
48
|
+
Press Enter at the prompt to upload your existing `ssh` key or create a new one, used for pushing code later on.
|
49
49
|
|
50
|
+
## Create a new Rails app (or upgrade an existing one)
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
```
|
54
|
-
:::- $ git clone https://github.com/rails/rails.git
|
55
|
-
```
|
52
|
+
To create a new app, first make sure that you're using Rails 6.x by running `rails -v`. If necessary, you can get the new version of rails by running the following:
|
56
53
|
|
57
54
|
```term
|
58
|
-
$ gem install rails --no-
|
55
|
+
:::>> $ gem install rails --no-document
|
59
56
|
```
|
60
57
|
|
61
|
-
Then create a new app:
|
58
|
+
Then create a new app and move into its root directory:
|
62
59
|
|
63
60
|
```term
|
64
|
-
$ rails new myapp --database=postgresql
|
65
|
-
:::-> $ ruby rails/railties/exe/rails new myapp --edge --database=postgresql
|
61
|
+
:::>- $ rails new myapp --database=postgresql
|
66
62
|
```
|
67
63
|
|
68
64
|
Then move into your application directory.
|
69
65
|
|
70
66
|
```term
|
71
|
-
|
67
|
+
:::>- $ cd myapp
|
72
68
|
```
|
73
69
|
|
74
|
-
|
70
|
+
Create a database locally:
|
75
71
|
|
76
|
-
|
72
|
+
```
|
73
|
+
:::>> $ bin/rails db:create
|
74
|
+
```
|
75
|
+
|
76
|
+
## Add the pg gem
|
77
77
|
|
78
|
-
If you
|
78
|
+
If you're using an existing app that was created without specifying `--database=postgresql`, you need to add the `pg` gem to your Rails project. Edit your `Gemfile` and change this line:
|
79
79
|
|
80
80
|
```ruby
|
81
81
|
gem 'sqlite3'
|
@@ -87,7 +87,7 @@ To this:
|
|
87
87
|
gem 'pg'
|
88
88
|
```
|
89
89
|
|
90
|
-
> callout We highly recommend using PostgreSQL during development. Maintaining [parity between your development](http://www.12factor.net/dev-prod-parity) and deployment environments prevents subtle bugs from being introduced because of differences between your environments. [Install Postgres locally](
|
90
|
+
> callout We highly recommend using PostgreSQL during development. Maintaining [parity between your development](http://www.12factor.net/dev-prod-parity) and deployment environments prevents subtle bugs from being introduced because of differences between your environments. [Install Postgres locally](heroku-postgresql#local-setup) now if it is not already on your system.
|
91
91
|
|
92
92
|
Now re-install your dependencies (to generate a new `Gemfile.lock`):
|
93
93
|
|
@@ -95,27 +95,25 @@ Now re-install your dependencies (to generate a new `Gemfile.lock`):
|
|
95
95
|
$ bundle install
|
96
96
|
```
|
97
97
|
|
98
|
-
|
98
|
+
For more information on why Postgres is recommended instead of Sqlite3, see [why you cannot use Sqlite3 on Heroku](sqlite3).
|
99
99
|
|
100
|
-
In addition to using the `pg` gem,
|
101
|
-
|
102
|
-
The development section of your `config/database.yml` file should look something like this:
|
100
|
+
In addition to using the `pg` gem, ensure that your `config/database.yml` file is using the `postgresql` adapter. The development section of your `config/database.yml` file should look something like this:
|
103
101
|
|
104
102
|
```term
|
105
|
-
:::>>
|
103
|
+
:::>> $ cat config/database.yml
|
106
104
|
```
|
107
105
|
|
108
106
|
Be careful here. If you omit the `sql` at the end of `postgresql` in the `adapter` section, your application will not work.
|
109
107
|
|
110
|
-
##
|
108
|
+
## Create a welcome page
|
111
109
|
|
112
|
-
Rails
|
110
|
+
Rails 6 no longer has a static index page in production by default. When you're using a new app, there will not be a root page in production, so we need to create one. We will first create a controller called `welcome` for our home page to live:
|
113
111
|
|
114
112
|
```term
|
115
|
-
|
113
|
+
:::>- $ rails generate controller welcome
|
116
114
|
```
|
117
115
|
|
118
|
-
Next we'll add an index page
|
116
|
+
Next we'll add an index page:
|
119
117
|
|
120
118
|
```html
|
121
119
|
:::>> file.write app/views/welcome/index.html.erb
|
@@ -128,21 +126,23 @@ Next we'll add an index page.
|
|
128
126
|
Now we need to make Rails route to this action. We'll edit `config/routes.rb` to set the index page to our new method:
|
129
127
|
|
130
128
|
```ruby
|
131
|
-
:::>> file.append config/routes.rb#
|
129
|
+
:::>> file.append config/routes.rb#2
|
132
130
|
root 'welcome#index'
|
133
131
|
```
|
134
132
|
|
135
133
|
You can verify that the page is there by running your server:
|
136
134
|
|
137
135
|
```term
|
138
|
-
|
136
|
+
:::>> background.start("rails server", name: "server")
|
137
|
+
:::-- background.stop(name: "server")
|
139
138
|
```
|
140
139
|
|
141
|
-
And visiting [http://localhost:3000](http://localhost:3000) in your browser. If you do not see the page, [use the logs](#view-
|
140
|
+
And visiting [http://localhost:3000](http://localhost:3000) in your browser. If you do not see the page, [use the logs](#view-logs) that are output to your server to debug.
|
142
141
|
|
143
142
|
## Heroku gems
|
144
143
|
|
145
|
-
Previous versions of Rails required you to add a gem to your project [rails_12factor](https://github.com/heroku/rails_12factor) to enable static asset serving and logging on Heroku. If you are deploying a new application this gem is not needed. If you are upgrading an existing application you can remove this gem provided you have the
|
144
|
+
Previous versions of Rails required you to add a gem to your project [rails_12factor](https://github.com/heroku/rails_12factor) to enable static asset serving and logging on Heroku. If you are deploying a new application, this gem is not needed. If you are upgrading an existing application, you can remove this gem provided you have the appropriate configuration in your `config/environments/production.rb` file:
|
145
|
+
|
146
146
|
|
147
147
|
```ruby
|
148
148
|
# config/environments/production.rb
|
@@ -155,13 +155,15 @@ if ENV["RAILS_LOG_TO_STDOUT"].present?
|
|
155
155
|
end
|
156
156
|
```
|
157
157
|
|
158
|
-
## Specify Ruby version
|
158
|
+
## Specify your Ruby version
|
159
|
+
|
160
|
+
Rails 6 requires Ruby 2.5.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the `ruby` DSL in your `Gemfile`. Depending on your version of Ruby that you are currently running it might look like this:
|
159
161
|
|
160
|
-
Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the `ruby` DSL in your `Gemfile`.
|
161
162
|
|
162
163
|
```ruby
|
163
|
-
|
164
|
-
|
164
|
+
:::-- $ sed -i'' -e '/^ruby/d' ./Gemfile
|
165
|
+
:::-> file.append Gemfile#4
|
166
|
+
ruby "2.6.6"
|
165
167
|
```
|
166
168
|
|
167
169
|
You should also be running the same version of Ruby locally. You can check this by running `$ ruby -v`. You can get more information on [specifying your Ruby version on Heroku here](https://devcenter.heroku.com/articles/ruby-versions).
|
@@ -171,11 +173,11 @@ You should also be running the same version of Ruby locally. You can check this
|
|
171
173
|
Heroku relies on [Git](http://git-scm.com/), a distributed source control management tool, for deploying your project. If your project is not already in Git, first verify that `git` is on your system:
|
172
174
|
|
173
175
|
```term
|
174
|
-
|
176
|
+
:::>- $ git --help
|
175
177
|
:::>> | $ head -n 5
|
176
178
|
```
|
177
179
|
|
178
|
-
If you don't see any output or get `command not found` you
|
180
|
+
If you don't see any output or get `command not found` you need to install Git on your system.
|
179
181
|
|
180
182
|
Once you've verified that Git works, first make sure you are in your Rails app directory by running `$ ls`:
|
181
183
|
|
@@ -188,9 +190,9 @@ The output should look like this:
|
|
188
190
|
Now run these commands in your Rails app directory to initialize and commit your code to Git:
|
189
191
|
|
190
192
|
```term
|
191
|
-
|
192
|
-
|
193
|
-
|
193
|
+
:::>- $ git init
|
194
|
+
:::>- $ git add .
|
195
|
+
:::>- $ git commit -m "init"
|
194
196
|
```
|
195
197
|
|
196
198
|
You can verify everything was committed correctly by running:
|
@@ -212,28 +214,31 @@ Make sure you are in the directory that contains your Rails app, then create an
|
|
212
214
|
You can verify that the remote was added to your project by running:
|
213
215
|
|
214
216
|
```term
|
215
|
-
:::>> $ git config --list | grep heroku
|
217
|
+
:::>> $ git config --list --local | grep heroku
|
216
218
|
```
|
217
219
|
|
218
|
-
If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise you
|
220
|
+
If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise, you can deploy your code. After you deploy your code, you need to migrate your database, make sure it is properly scaled, and use logs to debug any issues that come up.
|
221
|
+
|
222
|
+
>note
|
223
|
+
>Following changes in the industry, Heroku has updated our default git branch name to `main`. If the project you’re deploying uses `master` as its default branch name, use `git push heroku master`.
|
219
224
|
|
220
225
|
Deploy your code:
|
221
226
|
|
222
227
|
```term
|
223
|
-
:::>> $ git push heroku
|
228
|
+
:::>> $ git push heroku main
|
224
229
|
```
|
225
230
|
|
226
231
|
It is always a good idea to check to see if there are any warnings or errors in the output. If everything went well you can migrate your database.
|
227
232
|
|
228
233
|
## Migrate your database
|
229
234
|
|
230
|
-
If you are using the database in your application you need to manually migrate the database by running:
|
235
|
+
If you are using the database in your application, you need to manually migrate the database by running:
|
231
236
|
|
232
237
|
```term
|
233
238
|
$ heroku run rake db:migrate
|
234
239
|
```
|
235
240
|
|
236
|
-
Any commands after the `heroku run`
|
241
|
+
Any commands after the `heroku run` are executed on a Heroku [dyno](dynos). You can obtain an interactive shell session by running `$ heroku run bash`.
|
237
242
|
|
238
243
|
## Visit your application
|
239
244
|
|
@@ -242,7 +247,7 @@ You've deployed your code to Heroku. You can now instruct Heroku to execute a pr
|
|
242
247
|
Let's ensure we have one dyno running the `web` process type:
|
243
248
|
|
244
249
|
```term
|
245
|
-
|
250
|
+
:::>- $ heroku ps:scale web=1
|
246
251
|
```
|
247
252
|
|
248
253
|
You can check the state of the app's dynos. The `heroku ps` command lists the running dynos of your application:
|
@@ -263,7 +268,7 @@ You should now see the "Hello World" text we inserted above.
|
|
263
268
|
|
264
269
|
Heroku gives you a default web URL for simplicity while you are developing. When you are ready to scale up and use Heroku for production you can add your own [custom domain](https://devcenter.heroku.com/articles/custom-domains).
|
265
270
|
|
266
|
-
## View
|
271
|
+
## View logs
|
267
272
|
|
268
273
|
If you run into any problems getting your app to perform properly, you will need to check the logs.
|
269
274
|
|
@@ -281,11 +286,11 @@ $ heroku logs --tail
|
|
281
286
|
|
282
287
|
## Dyno sleeping and scaling
|
283
288
|
|
284
|
-
By default, new applications are deployed to a free dyno. Free apps will "sleep" to conserve resources. You can find more information about this behavior by reading about [free dyno behavior](
|
289
|
+
By default, new applications are deployed to a free dyno. Free apps will "sleep" to conserve resources. You can find more information about this behavior by reading about [free dyno behavior](free-dyno-hours).
|
285
290
|
|
286
291
|
To avoid dyno sleeping, you can upgrade to a hobby or professional dyno type as described in the [Dyno Types](dyno-types) article. For example, if you migrate your app to a professional dyno, you can easily scale it by running a command telling Heroku to execute a specific number of dynos, each running your web process type.
|
287
292
|
|
288
|
-
## Rails console
|
293
|
+
## Run the Rails console
|
289
294
|
|
290
295
|
Heroku allows you to run commands in a [one-off dyno](one-off-dynos) - scripts and applications that only need to be executed when needed - using the `heroku run` command. Use this to launch a Rails console process attached to your local terminal for experimenting in your app's environment:
|
291
296
|
|
@@ -297,7 +302,7 @@ irb(main):001:0> puts 1+1
|
|
297
302
|
|
298
303
|
Another useful command for debugging is `$ heroku run bash` which will spin up a new dyno and give you access to a bash session.
|
299
304
|
|
300
|
-
## Rake
|
305
|
+
## Run Rake commands
|
301
306
|
|
302
307
|
Rake can be run as an attached process exactly like the console:
|
303
308
|
|
@@ -305,9 +310,9 @@ Rake can be run as an attached process exactly like the console:
|
|
305
310
|
$ heroku run rake db:migrate
|
306
311
|
```
|
307
312
|
|
308
|
-
##
|
313
|
+
## Configure your webserver
|
309
314
|
|
310
|
-
By default, your app's web process runs `rails server`, which uses Puma in Rails
|
315
|
+
By default, your app's web process runs `rails server`, which uses Puma in Rails 6. If you are upgrading an app you'll need to add `puma` to your application `Gemfile`:
|
311
316
|
|
312
317
|
```ruby
|
313
318
|
gem 'puma'
|
@@ -316,14 +321,14 @@ gem 'puma'
|
|
316
321
|
Then run
|
317
322
|
|
318
323
|
```term
|
319
|
-
|
324
|
+
:::>- $ bundle install
|
320
325
|
```
|
321
326
|
|
322
|
-
Now you are ready to configure your app to use Puma. For this tutorial we will use the default `config/puma.rb` of that ships with Rails
|
327
|
+
Now you are ready to configure your app to use Puma. For this tutorial we will use the default `config/puma.rb` of that ships with Rails 6, but we recommend reading more about configuring your application for maximum performance by [reading the Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server).
|
323
328
|
|
324
329
|
Finally you will need to tell Heroku how to run your Rails app by creating a `Procfile` in the root of your application directory.
|
325
330
|
|
326
|
-
### Procfile
|
331
|
+
### Create a Procfile
|
327
332
|
|
328
333
|
Change the command used to launch your web process by creating a file called [Procfile](procfile) and entering this:
|
329
334
|
|
@@ -332,11 +337,11 @@ Change the command used to launch your web process by creating a file called [Pr
|
|
332
337
|
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
|
333
338
|
```
|
334
339
|
|
335
|
-
> Note:
|
340
|
+
> Note: This file must be named `Procfile` exactly.
|
336
341
|
|
337
342
|
We recommend generating a Puma config file based on [our Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server) for maximum performance.
|
338
343
|
|
339
|
-
To use the Procfile locally you can use `heroku local`.
|
344
|
+
To use the Procfile locally, you can use `heroku local`.
|
340
345
|
|
341
346
|
In addition to running commands in your `Procfile` `heroku local` can also help you manage environment variables locally through a `.env` file. Set the local `RACK_ENV` to development in your environment and a `PORT` to connect to. Before pushing to Heroku you'll want to test with the `RACK_ENV` set to production since this is the environment your Heroku app will run in.
|
342
347
|
|
@@ -350,30 +355,31 @@ In addition to running commands in your `Procfile` `heroku local` can also help
|
|
350
355
|
You'll also want to add `.env` to your `.gitignore` since this is for local environment setup.
|
351
356
|
|
352
357
|
```term
|
353
|
-
|
354
|
-
|
355
|
-
|
358
|
+
:::>- $ echo ".env" >> .gitignore
|
359
|
+
:::>- $ git add .gitignore
|
360
|
+
:::>- $ git commit -m "add .env to .gitignore"
|
361
|
+
```
|
362
|
+
|
363
|
+
If you're running Rails 6.0.0 you'll need to create a `tmp/pids` directory:
|
364
|
+
|
365
|
+
```term
|
366
|
+
:::>> $ mkdir -p tmp/pids
|
367
|
+
:::>> $ touch tmp/pids/.gitkeep
|
356
368
|
```
|
357
369
|
|
358
370
|
Test your Procfile locally using Foreman. You can now start your web server by running:
|
359
371
|
|
360
372
|
```term
|
361
|
-
|
362
|
-
|
363
|
-
11:06:35 AM web.1 | [18878] Puma starting in cluster mode...
|
364
|
-
11:06:35 AM web.1 | [18878] * Version 3.8.2 (ruby 2.4.1-p111), codename: Sassy Salamander
|
365
|
-
11:06:35 AM web.1 | [18878] * Min threads: 5, max threads: 5
|
366
|
-
11:06:35 AM web.1 | [18878] * Environment: development
|
367
|
-
11:06:35 AM web.1 | [18878] * Process workers: 2
|
368
|
-
11:06:35 AM web.1 | [18878] * Preloading application
|
373
|
+
:::>> background.start("heroku local", name: "local", wait: "Ctrl-C to stop", timeout: 15)
|
374
|
+
:::-- background.stop(name: "local")
|
369
375
|
```
|
370
376
|
|
371
377
|
Looks good, so press `Ctrl+C` to exit and you can deploy your changes to Heroku:
|
372
378
|
|
373
379
|
```term
|
374
|
-
|
375
|
-
|
376
|
-
|
380
|
+
:::>- $ git add .
|
381
|
+
:::>- $ git commit -m "use puma via procfile"
|
382
|
+
:::>- $ git push heroku main || git push heroku master
|
377
383
|
```
|
378
384
|
|
379
385
|
Check `ps`. You'll see that the web process uses your new command specifying Puma as the web server.
|
@@ -392,7 +398,7 @@ $ heroku logs
|
|
392
398
|
|
393
399
|
There are several options for invoking the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) when deploying to Heroku. For general information on the asset pipeline please see the [Rails 3.1+ Asset Pipeline on Heroku Cedar](rails-asset-pipeline) article.
|
394
400
|
|
395
|
-
The `config.assets.initialize_on_precompile` option has been removed is and not needed for Rails
|
401
|
+
The `config.assets.initialize_on_precompile` option has been removed is and not needed for Rails 6. Also, any failure in asset compilation will now cause the push to fail. For Rails 6 asset pipeline support see the [Ruby Support](ruby-support#rails-5-x-applications) page.
|
396
402
|
|
397
403
|
## Troubleshooting
|
398
404
|
|
@@ -440,6 +446,9 @@ end
|
|
440
446
|
|
441
447
|
Confirm it works locally, then push to Heroku.
|
442
448
|
|
443
|
-
##
|
449
|
+
## Next steps
|
450
|
+
|
451
|
+
Congratulations! You have deployed your first Rails 6 application to Heroku. Here's some recommended reading:
|
444
452
|
|
445
|
-
|
453
|
+
* Visit the [Ruby support category](/categories/ruby-support) to learn more about using Ruby and Rails on Heroku.
|
454
|
+
* The [Deployment category](/categories/deployment) provides a variety of powerful integrations and features to help streamline and simplify your deployments.
|