procsd 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +26 -15
- data/lib/procsd/cli.rb +22 -14
- data/lib/procsd/templates/service.erb +1 -1
- data/lib/procsd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da11e4c031739d5f93c9b4b4135da9f8589fbe04348ae9dad0a87b212e3de7ec
|
4
|
+
data.tar.gz: cea50b63954f02b21f713e6658feec63017b5718024b0447be5975b628d1ada9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b758ae08dbaa3682314f5e378e3b2db1396d73e47e7af096a3176dda7b00a59b040e028ef5af7712068dfcfb1e944367184f29606eb8d30d4af44a9198d49722
|
7
|
+
data.tar.gz: 95ca90f04d4f7a4c2e4569f526920cf91dd18b6fd7a431f17b69bb6509d6c6fc0d210c3e9c8ae96411c1429a9533ad80009fa4f413acef34a57acd0112bf2536
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,26 @@
|
|
1
1
|
# CHANGELOG
|
2
|
+
## 0.5.0
|
3
|
+
* **Breaking change:** Changed the way how to define SSL option for Ngnix configuration in procsd.yml (and by default contact email is not required anymore)
|
4
|
+
|
5
|
+
Was:
|
6
|
+
```yml
|
7
|
+
nginx:
|
8
|
+
server_name: my-domain.com
|
9
|
+
certbot:
|
10
|
+
email: some@email.com
|
11
|
+
```
|
12
|
+
|
13
|
+
Now:
|
14
|
+
```yml
|
15
|
+
nginx:
|
16
|
+
server_name: my-domain.com
|
17
|
+
ssl: true
|
18
|
+
```
|
19
|
+
|
20
|
+
If you want to provide email for Let's Encrypt, make sure that you have env variable CERTBOT_EMAIL=my_email while executing `$ procsd create`. You can put CERTBOT_EMAIL variable to the application's `.env` file (procsd will read this file if it exists) or simply call create command this way: `CERTBOT_EMAIL=my_email procsd create`.
|
21
|
+
|
22
|
+
* Change SyslogIdentifier for services from %n to %p
|
23
|
+
|
2
24
|
## 0.4.0
|
3
25
|
* **Breaking change:** commands in extended processes syntax were renamed from start/restart/stop to ExecStart/ExecReload/ExecStop:
|
4
26
|
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Can we have something similar on the cheap Ubuntu VPS from DigitalOcean? Yes we
|
|
8
8
|
|
9
9
|
## Getting started
|
10
10
|
|
11
|
-
> **Note:** latest version of Procsd is `0.
|
11
|
+
> **Note:** latest version of Procsd is `0.5.0`. Since version `0.4.0` there are some breaking changes. Check the [CHANGELOG.md](CHANGELOG.md). To update to the latest version, run `$ gem update procsd` or `$ bundle update procsd` (if you have already installed procsd).
|
12
12
|
|
13
13
|
> **Note:** Procsd works best with Capistrano integration: [vifreefly/capistrano-procsd](https://github.com/vifreefly/capistrano-procsd)
|
14
14
|
|
@@ -207,14 +207,14 @@ Use Ctrl-C to stop
|
|
207
207
|
|
208
208
|
By default `procsd exec` skip environment variables defined in `procsd.yml`. To run process with production environment, provide `--env` option as well: `procsd exec web --env`.
|
209
209
|
|
210
|
-
### Nginx
|
210
|
+
### Nginx integration (with automatic HTTPS)
|
211
211
|
> Before make sure that you have Nginx installed `sudo apt install nginx` and running `sudo systemctl status nginx`.
|
212
212
|
|
213
|
-
If one of your application processes is a web process, you can automatically setup Nginx config for it. Why? For example to serve static files (assets, images, etc) directly using fast Nginx, rather than application server. Or to enable SSL support (see below).
|
213
|
+
If one of your application processes is a web process, you can automatically setup Nginx (reverse proxy) config for it. Why? For example to serve static files (assets, images, etc) directly using fast Nginx, rather than application server. Or to enable SSL support (see below).
|
214
214
|
|
215
215
|
Add to your procsd.yml `nginx` section with `server_name` option defined:
|
216
216
|
|
217
|
-
> If you don't have domain
|
217
|
+
> If you don't have a domain for an application (or don't need it), you can add server IP instead: `server_name: 159.159.159.159`.
|
218
218
|
|
219
219
|
> If your application use multiple domains/subdomains, add all of them separated with space: `server_name: my-domain.com us.my-domain.com uk.my-domain.com`
|
220
220
|
|
@@ -222,6 +222,9 @@ Add to your procsd.yml `nginx` section with `server_name` option defined:
|
|
222
222
|
|
223
223
|
```yml
|
224
224
|
app: sample_app
|
225
|
+
processes:
|
226
|
+
web: bundle exec rails server -p $PORT
|
227
|
+
worker: bundle exec sidekiq -e $RAILS_ENV
|
225
228
|
formation: web=1,worker=2
|
226
229
|
environment:
|
227
230
|
PORT: 2501
|
@@ -231,7 +234,7 @@ nginx:
|
|
231
234
|
server_name: my-domain.com
|
232
235
|
```
|
233
236
|
|
234
|
-
Configuration is done! Run [procsd create](#create-an-application-export-to-systemd) to create app services with Nginx config:
|
237
|
+
Configuration is done! Run [procsd create](#create-an-application-export-to-systemd) to create app services with Nginx reverse proxy config:
|
235
238
|
|
236
239
|
```
|
237
240
|
deploy@server:~/sample_app$ procsd create
|
@@ -251,8 +254,8 @@ Link Nginx config file to the sites-enabled folder...
|
|
251
254
|
Nginx config created and daemon reloaded
|
252
255
|
```
|
253
256
|
|
254
|
-
<details
|
255
|
-
<summary
|
257
|
+
<details>
|
258
|
+
<summary>/etc/nginx/sites-available/sample_app</summary>
|
256
259
|
|
257
260
|
```
|
258
261
|
upstream app {
|
@@ -289,30 +292,35 @@ server {
|
|
289
292
|
error_page 422 /422.html;
|
290
293
|
}
|
291
294
|
```
|
292
|
-
</details>
|
295
|
+
</details><br>
|
296
|
+
|
297
|
+
Everything is done. Start app services (`procsd start`) and go to `http://my-domain.com` where you'll see your application proxying with Nginx.
|
293
298
|
|
294
299
|
#### Auto SSL using Certbot
|
295
300
|
|
296
301
|
To generate Nginx config with free SSL certificate (from [Let’s Encrypt](https://letsencrypt.org/)) included, you need to install [Certbot](https://certbot.eff.org/) on the remote server first:
|
297
302
|
|
298
303
|
```
|
304
|
+
sudo apt install software-properties-common
|
299
305
|
sudo add-apt-repository ppa:certbot/certbot
|
300
306
|
sudo apt update
|
301
307
|
sudo apt-get install python-certbot-nginx
|
302
308
|
```
|
303
309
|
|
304
|
-
|
310
|
+
> When you install certbot, it automatically setup a cron job (twice per day) to renew expiring certificates ([Automated Renewals](https://certbot.eff.org/docs/using.html#automated-renewals)), so you don't have to worry about renewing certificates manually.
|
305
311
|
|
306
|
-
|
312
|
+
Then update procsd.yml by adding `ssl: true`:
|
307
313
|
|
308
314
|
```yml
|
315
|
+
# ...
|
309
316
|
nginx:
|
310
317
|
server_name: my-domain.com
|
311
|
-
|
312
|
-
email: my-contact-email@gmail.com
|
318
|
+
ssl: true # added
|
313
319
|
```
|
314
320
|
|
315
|
-
Configuration is done. **Make sure that all domains defined in procsd (nginx.server_name) are
|
321
|
+
Configuration is done. **Make sure that all domains defined in procsd (nginx.server_name) are pointing to the server IP** where application is hosted. Then run `procsd create` as usual:
|
322
|
+
|
323
|
+
> By default Certbot obtaining certificate from _Let's Encrypt_ without a contact email. If you want to provide contact email, define env variable `CERTBOT_EMAIL` with your email in the `.env` file.
|
316
324
|
|
317
325
|
<details/>
|
318
326
|
<summary>Output</summary>
|
@@ -334,7 +342,7 @@ Create: /etc/nginx/sites-available/sample_app
|
|
334
342
|
Link Nginx config file to the sites-enabled folder...
|
335
343
|
Nginx config created and daemon reloaded
|
336
344
|
|
337
|
-
Execute: sudo certbot --agree-tos --no-eff-email --non-interactive --nginx -d my-domain.com -
|
345
|
+
Execute: sudo certbot --agree-tos --no-eff-email --non-interactive --nginx -d my-domain.com --register-unsafely-without-email
|
338
346
|
Saving debug log to /var/log/letsencrypt/letsencrypt.log
|
339
347
|
Plugins selected: Authenticator nginx, Installer nginx
|
340
348
|
Obtaining a new certificate
|
@@ -373,7 +381,9 @@ IMPORTANT NOTES:
|
|
373
381
|
|
374
382
|
Successfully installed SSL cert using certbot
|
375
383
|
```
|
376
|
-
</details>
|
384
|
+
</details><br>
|
385
|
+
|
386
|
+
That's it. Start app services (`procsd start`) and go to `https://my-domain.com` where you'll see your application proxying with Nginx and SSL enabled.
|
377
387
|
|
378
388
|
|
379
389
|
## All available commands
|
@@ -450,6 +460,7 @@ https://github.com/vifreefly/capistrano-procsd
|
|
450
460
|
|
451
461
|
|
452
462
|
## ToDo
|
463
|
+
* Add `procsd update` command to quickly update changed configuration (application units, nginx config, etc), instead of calling two separate commands (`procsd destroy` and `procsd create`)
|
453
464
|
* Add integration with [Inspeqtor](https://github.com/mperham/inspeqtor) to monitor application services and get alert notifications if something happened
|
454
465
|
|
455
466
|
|
data/lib/procsd/cli.rb
CHANGED
@@ -14,14 +14,6 @@ module Procsd
|
|
14
14
|
option :'add-to-sudoers', type: :boolean, banner: "Create sudoers rule at /etc/sudoers.d/app_name to allow manage app target without password prompt"
|
15
15
|
def create
|
16
16
|
raise ConfigurationError, "Can't find systemctl executable available" unless in_path?("systemctl")
|
17
|
-
options.each do |key, value|
|
18
|
-
next unless %w(user dir path).include? key
|
19
|
-
if value.nil? || value.empty?
|
20
|
-
say("Can't fetch value for --#{key}, please provide it's as an argument", :red) and return
|
21
|
-
else
|
22
|
-
say("Value of the --#{key} option: #{value}", :yellow)
|
23
|
-
end
|
24
|
-
end
|
25
17
|
|
26
18
|
preload!
|
27
19
|
if @config[:nginx]
|
@@ -32,9 +24,8 @@ module Procsd
|
|
32
24
|
unless @config.dig(:environment, "PORT")
|
33
25
|
raise ConfigurationError, "Please provide PORT environment variable in procsd.yml to use with Nginx"
|
34
26
|
end
|
35
|
-
if
|
27
|
+
if @config[:nginx]["ssl"]
|
36
28
|
raise ConfigurationError, "Can't find certbot executable available" unless in_path?("certbot")
|
37
|
-
raise ConfigurationError, "Provide email to generate cert using certbot" unless certbot["email"]
|
38
29
|
end
|
39
30
|
end
|
40
31
|
|
@@ -235,6 +226,15 @@ module Procsd
|
|
235
226
|
private
|
236
227
|
|
237
228
|
def perform_create
|
229
|
+
options.each do |key, value|
|
230
|
+
next unless %w(user dir path).include? key
|
231
|
+
if value.nil? || value.empty?
|
232
|
+
say("Can't fetch value for --#{key}, please provide it's as an argument", :red) and return
|
233
|
+
else
|
234
|
+
say("Value of the --#{key} option: #{value}", :yellow)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
238
|
generator = Generator.new(@config, options)
|
239
239
|
generator.generate_units(save: true)
|
240
240
|
|
@@ -271,17 +271,25 @@ module Procsd
|
|
271
271
|
say("Nginx config created and daemon reloaded", :green)
|
272
272
|
|
273
273
|
# Reference: https://certbot.eff.org/docs/using.html#certbot-command-line-options
|
274
|
-
|
274
|
+
# How it works in Caddy https://caddyserver.com/docs/automatic-https
|
275
|
+
if nginx["ssl"]
|
275
276
|
command = %w(sudo certbot --agree-tos --no-eff-email --redirect --non-interactive --nginx)
|
276
277
|
nginx["server_name"].split(" ").map(&:strip).each do |domain|
|
277
278
|
command.push("-d", domain)
|
278
279
|
end
|
279
280
|
|
280
|
-
|
281
|
+
if email = ENV["CERTBOT_EMAIL"]
|
282
|
+
command.push("--email", email)
|
283
|
+
else
|
284
|
+
command << "--register-unsafely-without-email"
|
285
|
+
end
|
286
|
+
|
287
|
+
say "Trying to obtain SSL certificate for Nginx config using Certbot..."
|
281
288
|
if execute command
|
282
|
-
say("Successfully installed SSL cert using
|
289
|
+
say("Successfully installed SSL cert using Certbot", :green)
|
283
290
|
else
|
284
|
-
|
291
|
+
msg = "Failed to install SSL cert using Certbot. Make sure that all provided domains are pointing to this server IP."
|
292
|
+
say(msg, :red)
|
285
293
|
end
|
286
294
|
end
|
287
295
|
end
|
data/lib/procsd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Afanasev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|