Skip to content

Commit bc25274

Browse files
cybercrediatorsdblock
authored andcommitted
Passenger deployment tutorial (#214)
1 parent 0cf1488 commit bc25274

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 0.12.1 (Next)
22

33
* Your contribution here.
4+
* [#214](https://github.com/slack-ruby/slack-ruby-bot/pull/214): Add passenger deployment documentation - [@cybercrediators](https://github.com/cybercrediators).
45

56
### 0.12.0 (2019/2/25)
67

DEPLOYMENT.md

+52
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,55 @@ heroku config:add SLACK_RUBY_BOT_ALIASES=":pong: table-tennis ping-pong"
3131
### Heroku Idling
3232

3333
Heroku free tier applications will idle. Either pay 7$ a month for the hobby dyno or use [UptimeRobot](http://uptimerobot.com) or similar to prevent your instance from sleeping or pay for a production dyno.
34+
35+
### Passenger Deployment
36+
37+
Deploying on your self-hosted server is fairly easy, it's pretty much following the [tutorial](https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby), but there are some configuration details to pay attention to.
38+
39+
+ Change or add the `gem 'puma'` entry in your `Gemfile` to `gem 'passenger'` and `bundle` it
40+
+ OPTIONAL: To use passenger for developing too, change the `Procfile` to `web: bundle exec passenger start`, to configure the local passenger you could provide an optional `Passenger.json` file ([configuration options](https://www.phusionpassenger.com/library/config/standalone/reference/))
41+
+ If you want to keep your logs etc. in the correct folders, you could add empty `public/`, `tmp/` and `log` directories. Passenger e.g. will automatically use them for local log files.
42+
+ Make sure, the right ruby version is [installed](https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/install_language_runtime.html) and your passenger is [ready](https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/install_passenger_main.html) to go.
43+
+ Clone the repository on your server (You could create a separate user for this) and install the dependencies, by running `bundle install` ([More information](https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/xenial/deploy_app.html))
44+
+ Edit the web-server configuration according to the examples below
45+
+ `PassengerMaxPreloaderIdleTime 0` or `passenger_max_preloader_idle_time 0;` makes sure to not automatically shut down the process after 5 minutes
46+
+ `PassengerPreStart http://url:port` or `passenger_pre_start http://url:port` will startup the application instantly, without the first HTTP GET-request needed for passenger
47+
+ To get the `/path/to/ruby` run `passenger-config about ruby-command` and copy the displayed path
48+
+ Check the config (`nginx -t`) and restart the server with `service nginx restart`
49+
+ Execute `passenger-status --verbose` to check if your app is working correctly
50+
+ Optional: restart the passenger app via `passenger-config restart-app /var/www/bot`
51+
52+
#### Nginx
53+
54+
```
55+
server {
56+
listen 80;
57+
server_name example.com;
58+
root /var/www/bot/public;
59+
passenger_enabled on;
60+
passenger_ruby /path/to/ruby
61+
passenger_max_preloader_idle_time 0;
62+
passenger_app_type rack;
63+
}
64+
65+
passenger_pre_start http://example.com:80/;
66+
```
67+
68+
#### Apache
69+
70+
```
71+
<VirtualHost *:80>
72+
ServerName example.com
73+
DocumentRoot /var/www/bot/public
74+
PassengerRuby /path/to/ruby
75+
PassengerMaxPreloaderIdleTime 0
76+
77+
<Directory /var/www/bot/public>
78+
Allow from all
79+
Options -MultiViews
80+
Require all granted
81+
</Directory>
82+
</VirtualHost>
83+
84+
PassengerPreStart http://example.com:80/
85+
```

TUTORIAL.md

+23
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ end
3636

3737
Run `bundle install` to get all the gems.
3838

39+
##### Passenger
40+
41+
To use passenger standalone change `gem 'puma'` to `gem 'passenger'`
42+
3943
#### Application
4044

4145
Create a folder called `slack-mathbot` and inside of it create `bot.rb`.
@@ -141,6 +145,25 @@ Create a `Procfile` which `foreman` will use when you run the `foreman start` co
141145
web: bundle exec puma -p $PORT
142146
```
143147

148+
#### Passenger
149+
150+
If you want to use passenger locally change it to:
151+
152+
```
153+
web: bundle exec passenger -p $PORT
154+
```
155+
156+
Add the following folders to your project root: 'tmp/', 'log/', 'public/'
157+
Passenger will automatically save the local logs to these folders.
158+
159+
Optional: Change the port in a `Passenger.json`
160+
161+
```
162+
{
163+
"port": "1234"
164+
}
165+
```
166+
144167
### Run the Bot
145168

146169
Run `foreman start`. Your bot should be running.

0 commit comments

Comments
 (0)