procsd 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 595c0d49250c7eb5075f7c01b7e6f28814bdc319cca686ad0ee0b5a5cea09c28
4
- data.tar.gz: de7f7d1df76a9ec2cfdb7c55a90ca87c89fcb387afb28addd52734f42bcf2193
3
+ metadata.gz: ecf9ac7491a94c05d51ac93c055b54da7bd03d2c049179eb467c0af1762162d6
4
+ data.tar.gz: 6eae45fdc21ee57016a19c830933664ae142e3f4a2d77537faff22e9cd888dae
5
5
  SHA512:
6
- metadata.gz: c410272886ffe376089154a6499ccb9da9634732b01b8c84c45627e6a3c5ff73b47106c6680095a3529f01d3f94ab928828c882a50b8f39e5164004063c14bae
7
- data.tar.gz: 6d9d84f9fd041b28a543dad0d458a5feed9ac0867062a82cd2af7926adda5d2e91be0162f972154b87cbb51442f1c49aadfb76dee30932406e593648568e0207
6
+ metadata.gz: 23f82ef2670831ae7d452e5f14a820225b02f964ec7009f8f067f3ae4c938c15d89491d53f7af10205aba479840c2e9e2dd7260998ac33ddccedfdbf52f315db
7
+ data.tar.gz: 9afd0665731d122bb1406a1bd4f1fcbeb16d092cf584ca66c1365931db75ea17482893774dd3829cdcce8745f885b408e7f9ff6bab3542a48c0a74ba42078555
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
  # CHANGELOG
2
+ ## 0.6.0
3
+ * **Breaking change:** Require Ruby >= 3.2.0 (dropping support for EOL versions)
4
+ * Fix: Use YAML.safe_load instead of deprecated YAML.load
5
+ * Fix: Use new `trim_mode` keyword argument for ERB.new
6
+ * Change: Relax bundler/rake version constraints to allow modern versions
7
+ * Add: Test coverage for generator output
8
+
9
+ Thanks to [@botandrose](https://github.com/botandrose) (Micah Geisel) for contributions!
10
+
2
11
  ## 0.5.5
3
12
  * Add: Allow to start/stop/restart particular service in the app target (example: `$ procsd start web`)
4
13
  * Add: RuntimeMaxSec option for process
data/README.md CHANGED
@@ -1,18 +1,14 @@
1
1
  # Procsd
2
2
 
3
- I do like the way how simple is managing of application processes in production on Heroku with [Procfile](https://devcenter.heroku.com/articles/procfile). How easily can be accessed application logs with [heroku logs](https://devcenter.heroku.com/articles/logging) command. Just type `heroku create` and you're good to go.
3
+ I really like how simple it is to manage application processes in production on Heroku with [Procfile](https://devcenter.heroku.com/articles/procfile). How easily you can access application logs with the [heroku logs](https://devcenter.heroku.com/articles/logging) command. Just type `heroku create` and you're good to go.
4
4
 
5
- Can we have something similar on the cheap Ubuntu VPS from DigitalOcean? Yes we can, all we need is a **systemd wrapper** which allows to export application processes from Procfile to system services, and control them/check status/access logs using simple commands.
5
+ Can we have something similar on a cheap Ubuntu VPS from DigitalOcean? Yes we can, all we need is a **systemd wrapper** that exports application processes from Procfile to system services, and controls them/checks status/accesses logs using simple commands.
6
6
 
7
- > These days most of Linux distributions (including Ubuntu) has systemd as a default system processes manager. That's why it is a good idea to use systemd for managing application processes in production (for simple cases).
7
+ > These days most Linux distributions (including Ubuntu) have systemd as their default system processes manager. That's why it is a good idea to use systemd for managing application processes in production (for simple cases).
8
8
 
9
9
  ## Getting started
10
10
 
11
- > **Note:** latest version of Procsd is `0.5.3`. 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
-
13
- > **Note:** Procsd works best with Capistrano integration: [vifreefly/capistrano-procsd](https://github.com/vifreefly/capistrano-procsd)
14
-
15
- Install `procsd` first: `$ gem install procsd`. Required Ruby version is `>= 2.3.0`.
11
+ Install `procsd` first: `$ gem install procsd`. Required Ruby version is `>= 3.2.0`.
16
12
 
17
13
  Let's say you have following application's Procfile:
18
14
 
@@ -20,7 +16,7 @@ Let's say you have following application's Procfile:
20
16
  web: bundle exec rails server -p $PORT
21
17
  worker: bundle exec sidekiq -e $RAILS_ENV
22
18
  ```
23
- and you want to have one instance of web process && two instances of worker process. Create inside application directory `procsd.yml` config file:
19
+ and you want to have one instance of the web process and two instances of the worker process. Create a `procsd.yml` config file inside the application directory:
24
20
 
25
21
  ```yaml
26
22
  app: sample_app
@@ -50,7 +46,7 @@ Create: /etc/systemd/system/sample_app-web.1.service
50
46
  Create: /etc/systemd/system/sample_app-worker.1.service
51
47
  Create: /etc/systemd/system/sample_app-worker.2.service
52
48
  Create: /etc/systemd/system/sample_app.target
53
- Reloaded configuraion (daemon-reload)
49
+ Reloaded configuration (daemon-reload)
54
50
  Created symlink /etc/systemd/system/multi-user.target.wants/sample_app.target → /etc/systemd/system/sample_app.target.
55
51
  Enabled app target sample_app.target
56
52
  App services were created and enabled. Run `start` to start them
@@ -62,15 +58,15 @@ deploy ALL=NOPASSWD: /bin/systemctl start sample_app.target, /bin/systemctl stop
62
58
  You can provide additional options for `create` command:
63
59
  * `--user` - name of the user, default is current _$USER_ env variable
64
60
  * `--dir` - application's working directory, default is current _$PWD_ env variable
65
- * `--path` - $PATH to include to the each service. Default is current _$PATH_ env variable
66
- * `--add-to-sudoers` - if option present, procsd will create sudoers rule file `/etc/sudoers.d/app_name` which allow to start/stop/restart app services without a password prompt (passwordless sudo).
67
- * `--or-restart` - if option provided and services already created, procsd will skip creation and call instead `restart` command. Otherwise (if services are not present), they will be created and (in additional) started. It's useful option for deployment tools like Capistrano, Mina, etc.
61
+ * `--path` - $PATH to include in each service. Default is current _$PATH_ env variable
62
+ * `--add-to-sudoers` - if this option is present, procsd will create a sudoers rule file `/etc/sudoers.d/app_name` which allows starting/stopping/restarting app services without a password prompt (passwordless sudo).
63
+ * `--or-restart` - if this option is provided and services are already created, procsd will skip creation and call the `restart` command instead. Otherwise (if services are not present), they will be created and additionally started. This is a useful option for deployment tools like Capistrano, Mina, etc.
68
64
 
69
65
 
70
66
  ### Start application
71
67
  > Other control commands: `stop` and `restart`
72
68
 
73
- > You can start/stop/restart a particular process by providing it's name, i.e.: `$ procsd restart worker`
69
+ > You can start/stop/restart a particular process by providing its name, e.g.: `$ procsd restart worker`
74
70
 
75
71
  ```
76
72
  deploy@server:~/sample_app$ procsd start
@@ -206,7 +202,7 @@ Puma starting in single mode...
206
202
  Use Ctrl-C to stop
207
203
  ```
208
204
 
209
- `procsd exec` requres all the environment variables defined in `environment` section of `procsd.yml` config file.
205
+ `procsd exec` requires all the environment variables defined in `environment` section of `procsd.yml` config file.
210
206
 
211
207
  Sometimes in development mode you need different environment configuration. For that you can add additional environment section `dev_environment` and require it as well using `--dev` flag, example:
212
208
 
@@ -227,13 +223,13 @@ dev_environment:
227
223
  deploy@server:~/sample_app$ procsd exec web --dev
228
224
  ```
229
225
 
230
- > In case if `dev_environment` has env variable with the same name like in `environment`, this variable will be rewritten with value from `dev_environment`.
226
+ > If `dev_environment` has an env variable with the same name as one in `environment`, it will be overwritten with the value from `dev_environment`.
231
227
 
232
228
 
233
229
  ### Nginx integration (with automatic HTTPS)
234
- > Before make sure that you have Nginx installed `sudo apt install nginx` and running `sudo systemctl status nginx`.
230
+ > First, make sure that you have Nginx installed (`sudo apt install nginx`) and running (`sudo systemctl status nginx`).
235
231
 
236
- 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, and all other files located in `public` folder or another customly defined folder) directly using fast Nginx, rather than application server. Or to enable SSL support (see below).
232
+ If one of your application processes is a web process, you can automatically set up an Nginx (reverse proxy) config for it. Why? For example, to serve static files (assets, images, and all other files located in `public` folder or another custom folder) directly using Nginx, rather than the application server. Or to enable SSL support (see below).
237
233
 
238
234
  Add to your procsd.yml `nginx` section with `server_name` option defined:
239
235
 
@@ -267,7 +263,7 @@ Create: /etc/systemd/system/sample_app-web.1.service
267
263
  Create: /etc/systemd/system/sample_app-worker.1.service
268
264
  Create: /etc/systemd/system/sample_app-worker.2.service
269
265
  Create: /etc/systemd/system/sample_app.target
270
- Reloaded configuraion (daemon-reload)
266
+ Reloaded configuration (daemon-reload)
271
267
  Created symlink /etc/systemd/system/multi-user.target.wants/sample_app.target → /etc/systemd/system/sample_app.target.
272
268
  Enabled app target sample_app.target
273
269
  App services were created and enabled. Run `start` to start them
@@ -345,7 +341,7 @@ Configuration is done. **Make sure that all domains defined in procsd (nginx.ser
345
341
 
346
342
  > 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.
347
343
 
348
- <details/>
344
+ <details>
349
345
  <summary>Output</summary>
350
346
 
351
347
  ```
@@ -356,7 +352,7 @@ Create: /etc/systemd/system/sample_app-web.1.service
356
352
  Create: /etc/systemd/system/sample_app-worker.1.service
357
353
  Create: /etc/systemd/system/sample_app-worker.2.service
358
354
  Create: /etc/systemd/system/sample_app.target
359
- Reloaded configuraion (daemon-reload)
355
+ Reloaded configuration (daemon-reload)
360
356
  Created symlink /etc/systemd/system/multi-user.target.wants/sample_app.target → /etc/systemd/system/sample_app.target.
361
357
  Enabled app target sample_app.target
362
358
  App services were created and enabled. Run `start` to start them
@@ -409,7 +405,7 @@ Successfully installed SSL cert using certbot
409
405
  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.
410
406
 
411
407
 
412
- <details/>
408
+ <details>
413
409
  <summary>Note about using Cloudflare CDN</summary><br>
414
410
 
415
411
  If you use Cloudflare CDN, that means the process of obtaining Let's Encrypt SSL Certificate will fail. To fix it, install `python-certbot-dns-cloudflare` package:
@@ -490,15 +486,15 @@ Commands:
490
486
 
491
487
  ## Difference with Foreman
492
488
 
493
- [Foreman](http://ddollar.github.io/foreman/) itself designed for _development_ (not production) usage only and doing it great. Yes, Foreman allows to [export](http://ddollar.github.io/foreman/#EXPORTING) Procfile to the Systemd, but that's all. After export you have to manually use `systemctl` and `journalctl` to manage/check exported services. Procsd not only exports application, but provides [simple commands](#all-available-commands) to manage exported target.
489
+ [Foreman](http://ddollar.github.io/foreman/) itself is designed for _development_ (not production) usage only and does it great. Yes, Foreman allows you to [export](http://ddollar.github.io/foreman/#EXPORTING) Procfile to Systemd, but that's all. After export you have to manually use `systemctl` and `journalctl` to manage/check exported services. Procsd not only exports the application, but provides [simple commands](#all-available-commands) to manage the exported target.
494
490
 
495
- * Foreman systemd export uses [dymamic](https://fedoramagazine.org/systemd-template-unit-files/) services templates and as a result generates quite a lot of files/folders in the systemd directory even for a simple application.
491
+ * Foreman systemd export uses [dynamic](https://fedoramagazine.org/systemd-template-unit-files/) services templates and as a result generates quite a lot of files/folders in the systemd directory even for a simple application.
496
492
 
497
- * Services generated using Foreman contain [$PORT variable](http://ddollar.github.io/foreman/#PROCFILE) in their names (and it's [undocumented](http://ddollar.github.io/foreman/#SYSTEMD-EXPORT) logic). For example for Procfile and formation `web=1,worker=2` (from example above), exported services with Foreman will be: `sample_app-web@2500.service`, `sample_app-worker@2600.service` and `sample_app-worker@2601.service`. My opinion about this approach: it's complicated. Why is there required PORT variable in the services names? Procsd following one rule: simplicity. For export it uses static service files (that means for each process will be generated it's own service file) and services names have predictable, Heroku-like names.
493
+ * Services generated using Foreman contain the [$PORT variable](http://ddollar.github.io/foreman/#PROCFILE) in their names (and it's [undocumented](http://ddollar.github.io/foreman/#SYSTEMD-EXPORT) logic). For example, for Procfile and formation `web=1,worker=2` (from the example above), exported services with Foreman will be: `sample_app-web@2500.service`, `sample_app-worker@2600.service` and `sample_app-worker@2601.service`. My opinion about this approach: it's complicated. Why is the PORT variable required in the service names? Procsd follows one rule: simplicity. For export it uses static service files (that means for each process its own service file will be generated) and service names are predictable, Heroku-like.
498
494
 
499
495
  * Procsd export can provide additional stop/restart commands for each service (see _Notes_ below).
500
496
 
501
- * To delete existing app services from Systemd, there is `procsd destroy` command. It is doing the following: stop services if they are running, delete all required systemd files from systemd directory, and restart systemd (`daemon-reload`). This command especially useful while testing, when you need frequently create/update configuration.
497
+ * To delete existing app services from Systemd, there is the `procsd destroy` command. It does the following: stops services if they are running, deletes all required systemd files from the systemd directory, and restarts systemd (`daemon-reload`). This command is especially useful while testing, when you need to frequently create/update configuration.
502
498
 
503
499
 
504
500
  ## Notes
@@ -555,7 +551,7 @@ processes:
555
551
  https://github.com/vifreefly/capistrano-procsd
556
552
 
557
553
 
558
- ## ToDo
554
+ ## TODO
559
555
  * 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`)
560
556
 
561
557
 
data/lib/procsd/cli.rb CHANGED
@@ -58,7 +58,7 @@ module Procsd
58
58
  end
59
59
 
60
60
  if execute %w(sudo systemctl daemon-reload)
61
- say("Reloaded configuraion (daemon-reload)", :green)
61
+ say("Reloaded configuration (daemon-reload)", :green)
62
62
  end
63
63
  say("App services were stopped, disabled and removed", :green)
64
64
 
@@ -289,7 +289,7 @@ module Procsd
289
289
  generator.generate_units(save: true)
290
290
 
291
291
  if execute %w(sudo systemctl daemon-reload)
292
- say("Reloaded configuraion (daemon-reload)", :green)
292
+ say("Reloaded configuration (daemon-reload)", :green)
293
293
  end
294
294
 
295
295
  enable
@@ -420,7 +420,7 @@ module Procsd
420
420
 
421
421
  raise ConfigurationError, "Config file procsd.yml doesn't exists" unless File.exist? "procsd.yml"
422
422
  begin
423
- procsd = YAML.load(ERB.new(File.read "procsd.yml").result)
423
+ procsd = YAML.safe_load(ERB.new(File.read "procsd.yml").result)
424
424
  rescue => e
425
425
  raise ConfigurationError, "Can't read procsd.yml: #{e.inspect}"
426
426
  end
@@ -433,7 +433,7 @@ module Procsd
433
433
  msg = "Procfile doesn't exists. Define processes in procsd.yml or create Procfile"
434
434
  raise ConfigurationError, msg unless File.exist? "Procfile"
435
435
  begin
436
- procfile = YAML.load_file("Procfile")
436
+ procfile = YAML.safe_load_file("Procfile")
437
437
  rescue => e
438
438
  raise ConfigurationError, "Can't read Procfile: #{e.inspect}"
439
439
  end
@@ -99,7 +99,7 @@ module Procsd
99
99
  b.local_variable_set(:config, conf)
100
100
  template_path = File.join(File.dirname(__FILE__), "templates/#{template_name}.erb")
101
101
  content = File.read(template_path)
102
- ERB.new(content, nil, "-").result(b)
102
+ ERB.new(content, trim_mode: "-").result(b)
103
103
  end
104
104
 
105
105
  def write_file!(dest_path, content)
@@ -1,3 +1,3 @@
1
1
  module Procsd
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
data/procsd.gemspec CHANGED
@@ -22,12 +22,12 @@ Gem::Specification.new do |spec|
22
22
  spec.bindir = "exe"
23
23
  spec.executables = "procsd"
24
24
  spec.require_paths = ["lib"]
25
- spec.required_ruby_version = ">= 2.3.0"
25
+ spec.required_ruby_version = ">= 3.2.0"
26
26
 
27
27
  spec.add_dependency "thor"
28
28
  spec.add_dependency "dotenv"
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.16"
31
- spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "bundler", ">= 1.16"
31
+ spec.add_development_dependency "rake", ">= 10.0"
32
32
  spec.add_development_dependency "minitest", "~> 5.0"
33
33
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Afanasev
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: thor
@@ -42,28 +41,28 @@ dependencies:
42
41
  name: bundler
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - "~>"
44
+ - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '1.16'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - "~>"
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: '1.16'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: rake
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - "~>"
58
+ - - ">="
60
59
  - !ruby/object:Gem::Version
61
60
  version: '10.0'
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - "~>"
65
+ - - ">="
67
66
  - !ruby/object:Gem::Version
68
67
  version: '10.0'
69
68
  - !ruby/object:Gem::Dependency
@@ -80,7 +79,6 @@ dependencies:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
81
  version: '5.0'
83
- description:
84
82
  email:
85
83
  - vicfreefly@gmail.com
86
84
  executables:
@@ -109,7 +107,6 @@ homepage: https://github.com/vifreefly/procsd
109
107
  licenses:
110
108
  - MIT
111
109
  metadata: {}
112
- post_install_message:
113
110
  rdoc_options: []
114
111
  require_paths:
115
112
  - lib
@@ -117,15 +114,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
114
  requirements:
118
115
  - - ">="
119
116
  - !ruby/object:Gem::Version
120
- version: 2.3.0
117
+ version: 3.2.0
121
118
  required_rubygems_version: !ruby/object:Gem::Requirement
122
119
  requirements:
123
120
  - - ">="
124
121
  - !ruby/object:Gem::Version
125
122
  version: '0'
126
123
  requirements: []
127
- rubygems_version: 3.0.3
128
- signing_key:
124
+ rubygems_version: 4.0.1
129
125
  specification_version: 4
130
126
  summary: Manage your application processes in production hassle-free like Heroku CLI
131
127
  with Procfile and Systemd