Skip to content

Commit 2c3c41f

Browse files
authored
Consistent guide examples for using preload (#287)
1 parent b774a2d commit 2c3c41f

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

guides/deployment/readme.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Falcon can be deployed into production either as a standalone application server
1919
Here is a basic example which hosts a rack application using :
2020

2121
~~~ ruby
22-
#!/usr/bin/env falcon-host
22+
#!/usr/bin/env falcon host
2323
# frozen_string_literal: true
2424

2525
require "falcon/environment/rack"
@@ -47,7 +47,7 @@ These configuration blocks are evaluated using [async-service](https://github.co
4747
The environment configuration is defined in the `Falcon::Environment` module. The {ruby Falcon::Environment::Application} environment supports the generic virtual host functionality, but you can customise any parts of the configuration, e.g. to bind a production host to `localhost:3000` using plaintext HTTP/2:
4848

4949
~~~ ruby
50-
#!/usr/bin/env falcon-host
50+
#!/usr/bin/env falcon host
5151
# frozen_string_literal: true
5252

5353
require "falcon/environment/rack"
@@ -59,7 +59,9 @@ service hostname do
5959
include Falcon::Environment::LetsEncryptTLS
6060

6161
endpoint do
62-
Async::HTTP::Endpoint.parse('http://localhost:3000').with(protocol: Async::HTTP::Protocol::HTTP2)
62+
Async::HTTP::Endpoint
63+
.parse('http://localhost:3000')
64+
.with(protocol: Async::HTTP::Protocol::HTTP2)
6365
end
6466
end
6567

@@ -84,6 +86,7 @@ web: bundle exec falcon host
8486
# falcon.rb
8587

8688
#!/usr/bin/env -S falcon host
89+
# frozen_string_literal: true
8790

8891
require "falcon/environment/rack"
8992

@@ -105,13 +108,17 @@ service hostname do
105108
# Heroku only supports HTTP/1.1 at the time of this writing. Review the following for possible updates in the future:
106109
# https://devcenter.heroku.com/articles/http-routing#http-versions-supported
107110
# https://github.com/heroku/roadmap/issues/34
108-
endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:#{port}").with(protocol: Async::HTTP::Protocol::HTTP11)
111+
endpoint Async::HTTP::Endpoint
112+
.parse("http://0.0.0.0:#{port}")
113+
.with(protocol: Async::HTTP::Protocol::HTTP11)
109114
end
110115
~~~
111116

112117
~~~ ruby
113118
# preload.rb
114119

120+
# frozen_string_literal: true
121+
115122
require_relative "config/environment"
116123
~~~
117124

@@ -129,17 +136,16 @@ You need to create a `falcon.rb` configuration in the root of your applications,
129136

130137
~~~ bash
131138
cat /srv/http/example.com/falcon.rb
132-
#!/usr/bin/env falcon-host
139+
#!/usr/bin/env falcon host
140+
# frozen_string_literal: true
133141

134142
require "falcon/environment/self_signed_tls"
135143
require "falcon/environment/rack"
136144
require "falcon/environment/supervisor"
137145

138146
service "hello.localhost" do
139-
140147
include Falcon::Environment::SelfSignedTLS
141148
include Falcon::Environment::Rack
142-
143149
end
144150

145151
service "supervisor" do

guides/rails-integration/readme.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ This guide explains how to host Rails applications with Falcon.
66

77
Because Rails apps are built on top of Rack, they are compatible with Falcon.
88

9-
1. Add `gem 'falcon'` to your `Gemfile` and perhaps remove `gem 'puma'` once you are satisfied with the change.
9+
1. Add `gem "falcon"` to your `Gemfile` and perhaps remove `gem "puma"` once you are satisfied with the change.
1010
2. Run `falcon serve` to start a local development server.
1111

1212
We do not recommend using Rails older than v7.1 with Falcon. If you are using an older version of Rails, you should upgrade to the latest version before using Falcon.
1313

1414
Falcon assumes HTTPS by default (so that browsers can use HTTP2). To run under HTTP in development you can bind it to an explicit scheme, host and port:
1515

16-
```
16+
~~~ bash
1717
falcon serve -b http://localhost:3000
18-
```
18+
~~~
1919

2020
### Production
2121

2222
The `falcon serve` command is only intended to be used for local development. Follow these steps to run a production Rails app with Falcon:
2323

2424
1. Create a `falcon.rb` file
2525

26-
```rb
26+
~~~ rb
2727
#!/usr/bin/env -S falcon host
2828
# frozen_string_literal: true
2929

@@ -32,17 +32,22 @@ require "falcon/environment/rack"
3232
hostname = File.basename(__dir__)
3333
port = ENV["PORT"] || 3000
3434

35+
preload "preload.rb"
36+
3537
service hostname do
3638
include Falcon::Environment::Rack
39+
3740
endpoint Async::HTTP::Endpoint.parse("http://0.0.0.0:#{port}")
3841
end
39-
```
42+
~~~
4043

4144
2. Create a `preload.rb` file
4245

43-
```rb
46+
~~~ rb
47+
# frozen_string_literal: true
48+
4449
require_relative "config/environment"
45-
```
50+
~~~
4651

4752
3. Run the production server with `bundle exec falcon host`
4853

0 commit comments

Comments
 (0)