procsd 0.5.4 → 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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +39 -30
- data/lib/procsd/cli.rb +55 -24
- data/lib/procsd/generator.rb +1 -1
- data/lib/procsd/templates/service.erb +4 -0
- data/lib/procsd/version.rb +1 -1
- data/procsd.gemspec +3 -3
- metadata +8 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecf9ac7491a94c05d51ac93c055b54da7bd03d2c049179eb467c0af1762162d6
|
|
4
|
+
data.tar.gz: 6eae45fdc21ee57016a19c830933664ae142e3f4a2d77537faff22e9cd888dae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 23f82ef2670831ae7d452e5f14a820225b02f964ec7009f8f067f3ae4c938c15d89491d53f7af10205aba479840c2e9e2dd7260998ac33ddccedfdbf52f315db
|
|
7
|
+
data.tar.gz: 9afd0665731d122bb1406a1bd4f1fcbeb16d092cf584ca66c1365931db75ea17482893774dd3829cdcce8745f885b408e7f9ff6bab3542a48c0a74ba42078555
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
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
|
+
|
|
11
|
+
## 0.5.5
|
|
12
|
+
* Add: Allow to start/stop/restart particular service in the app target (example: `$ procsd start web`)
|
|
13
|
+
* Add: RuntimeMaxSec option for process
|
|
14
|
+
|
|
2
15
|
## 0.5.4
|
|
3
16
|
* Add: information how to use SSL integration with Cloudflare CDN enabled
|
|
4
17
|
* Add: procsd config certbot_command command
|
data/README.md
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
# Procsd
|
|
2
2
|
|
|
3
|
-
I
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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,21 +58,22 @@ 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
|
|
66
|
-
* `--add-to-sudoers` - if option present, procsd will create sudoers rule file `/etc/sudoers.d/app_name` which
|
|
67
|
-
* `--or-restart` - if option provided and services already created, procsd will skip creation and call
|
|
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
|
|
|
69
|
+
> You can start/stop/restart a particular process by providing its name, e.g.: `$ procsd restart worker`
|
|
70
|
+
|
|
73
71
|
```
|
|
74
72
|
deploy@server:~/sample_app$ procsd start
|
|
75
73
|
|
|
76
74
|
Started app services (sample_app.target)
|
|
77
75
|
```
|
|
78
76
|
|
|
79
|
-
|
|
80
77
|
### Check the status
|
|
81
78
|
> You can filter processes, like `$ procsd status worker` (show status only for worker processes) or `$ procsd status worker.2` (show status only for worker.2 process)
|
|
82
79
|
|
|
@@ -205,7 +202,7 @@ Puma starting in single mode...
|
|
|
205
202
|
Use Ctrl-C to stop
|
|
206
203
|
```
|
|
207
204
|
|
|
208
|
-
`procsd exec`
|
|
205
|
+
`procsd exec` requires all the environment variables defined in `environment` section of `procsd.yml` config file.
|
|
209
206
|
|
|
210
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:
|
|
211
208
|
|
|
@@ -226,13 +223,13 @@ dev_environment:
|
|
|
226
223
|
deploy@server:~/sample_app$ procsd exec web --dev
|
|
227
224
|
```
|
|
228
225
|
|
|
229
|
-
>
|
|
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`.
|
|
230
227
|
|
|
231
228
|
|
|
232
229
|
### Nginx integration (with automatic HTTPS)
|
|
233
|
-
>
|
|
230
|
+
> First, make sure that you have Nginx installed (`sudo apt install nginx`) and running (`sudo systemctl status nginx`).
|
|
234
231
|
|
|
235
|
-
If one of your application processes is a web process, you can automatically
|
|
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).
|
|
236
233
|
|
|
237
234
|
Add to your procsd.yml `nginx` section with `server_name` option defined:
|
|
238
235
|
|
|
@@ -266,7 +263,7 @@ Create: /etc/systemd/system/sample_app-web.1.service
|
|
|
266
263
|
Create: /etc/systemd/system/sample_app-worker.1.service
|
|
267
264
|
Create: /etc/systemd/system/sample_app-worker.2.service
|
|
268
265
|
Create: /etc/systemd/system/sample_app.target
|
|
269
|
-
Reloaded
|
|
266
|
+
Reloaded configuration (daemon-reload)
|
|
270
267
|
Created symlink /etc/systemd/system/multi-user.target.wants/sample_app.target → /etc/systemd/system/sample_app.target.
|
|
271
268
|
Enabled app target sample_app.target
|
|
272
269
|
App services were created and enabled. Run `start` to start them
|
|
@@ -320,7 +317,7 @@ Everything is done. Start app services (`procsd start`) and go to `http://my-dom
|
|
|
320
317
|
|
|
321
318
|
#### Auto SSL using Certbot
|
|
322
319
|
|
|
323
|
-
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:
|
|
320
|
+
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. For Ubuntu 18.04 (check here instructions for other versions https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx):
|
|
324
321
|
|
|
325
322
|
```bash
|
|
326
323
|
$ sudo apt install software-properties-common
|
|
@@ -344,7 +341,7 @@ Configuration is done. **Make sure that all domains defined in procsd (nginx.ser
|
|
|
344
341
|
|
|
345
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.
|
|
346
343
|
|
|
347
|
-
<details
|
|
344
|
+
<details>
|
|
348
345
|
<summary>Output</summary>
|
|
349
346
|
|
|
350
347
|
```
|
|
@@ -355,7 +352,7 @@ Create: /etc/systemd/system/sample_app-web.1.service
|
|
|
355
352
|
Create: /etc/systemd/system/sample_app-worker.1.service
|
|
356
353
|
Create: /etc/systemd/system/sample_app-worker.2.service
|
|
357
354
|
Create: /etc/systemd/system/sample_app.target
|
|
358
|
-
Reloaded
|
|
355
|
+
Reloaded configuration (daemon-reload)
|
|
359
356
|
Created symlink /etc/systemd/system/multi-user.target.wants/sample_app.target → /etc/systemd/system/sample_app.target.
|
|
360
357
|
Enabled app target sample_app.target
|
|
361
358
|
App services were created and enabled. Run `start` to start them
|
|
@@ -408,7 +405,7 @@ Successfully installed SSL cert using certbot
|
|
|
408
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.
|
|
409
406
|
|
|
410
407
|
|
|
411
|
-
<details
|
|
408
|
+
<details>
|
|
412
409
|
<summary>Note about using Cloudflare CDN</summary><br>
|
|
413
410
|
|
|
414
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:
|
|
@@ -489,15 +486,15 @@ Commands:
|
|
|
489
486
|
|
|
490
487
|
## Difference with Foreman
|
|
491
488
|
|
|
492
|
-
[Foreman](http://ddollar.github.io/foreman/) itself designed for _development_ (not production) usage only and
|
|
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.
|
|
493
490
|
|
|
494
|
-
* Foreman systemd export uses [
|
|
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.
|
|
495
492
|
|
|
496
|
-
* 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
|
|
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.
|
|
497
494
|
|
|
498
495
|
* Procsd export can provide additional stop/restart commands for each service (see _Notes_ below).
|
|
499
496
|
|
|
500
|
-
* To delete existing app services from Systemd, there is `procsd destroy` command. It
|
|
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.
|
|
501
498
|
|
|
502
499
|
|
|
503
500
|
## Notes
|
|
@@ -519,9 +516,9 @@ Execute: journalctl --no-pager --no-hostname --all --output short-iso -n 3 --uni
|
|
|
519
516
|
|
|
520
517
|
* You can use extended format of processes commands inside `procsd.yml` to provide additional restart/stop commands for each process:
|
|
521
518
|
|
|
522
|
-
> All possible options:
|
|
519
|
+
> All possible options: [ExecStart](https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart=) (default command to start a process), [ExecReload](https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecReload=), and [ExecStop](https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStop=).
|
|
523
520
|
|
|
524
|
-
> If procsd.yml has `processes:` option defined, then content of Procfile will be ignored
|
|
521
|
+
> If procsd.yml has `processes:` option defined, then content of Procfile (if it exists) will be ignored.
|
|
525
522
|
|
|
526
523
|
```yml
|
|
527
524
|
app: sample_app
|
|
@@ -534,6 +531,18 @@ processes:
|
|
|
534
531
|
|
|
535
532
|
Why? For example default Ruby on Rails application server [Puma](http://puma.io/) supports [Phased or Rolling restart](https://github.com/puma/puma/blob/master/docs/restart.md#normal-vs-hot-vs-phased-restart) feature. If you provide separate `ExecReload`command for a process, then this command will be called while executing `$ procsd restart` by systemd instead of just killing and starting process again.
|
|
536
533
|
|
|
534
|
+
* Another option you can provide for each process is [RuntimeMaxSec](https://www.freedesktop.org/software/systemd/man/systemd.service.html#RuntimeMaxSec=). It is used to automatically restart a process every N period of time. Could be useful for worker types of processes (like Sidekiq) where process memory could increase while running:
|
|
535
|
+
|
|
536
|
+
> Example values for RuntimeMaxSec: `30s` (30 seconds), `5m` (5 minutes), `3h` (3 hours), `1d` (1 day).
|
|
537
|
+
|
|
538
|
+
```yml
|
|
539
|
+
app: sample_app
|
|
540
|
+
processes:
|
|
541
|
+
web:
|
|
542
|
+
ExecStart: bundle exec rails server -p $PORT
|
|
543
|
+
RuntimeMaxSec: 12h
|
|
544
|
+
```
|
|
545
|
+
|
|
537
546
|
* If you use Nginx integration but default Nginx requests timeout (60s) is too small for you, [you can set a custom timeout](https://serverfault.com/a/777753) in the global Nginx config.
|
|
538
547
|
|
|
539
548
|
|
|
@@ -542,7 +551,7 @@ Why? For example default Ruby on Rails application server [Puma](http://puma.io/
|
|
|
542
551
|
https://github.com/vifreefly/capistrano-procsd
|
|
543
552
|
|
|
544
553
|
|
|
545
|
-
##
|
|
554
|
+
## TODO
|
|
546
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`)
|
|
547
556
|
|
|
548
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
|
|
61
|
+
say("Reloaded configuration (daemon-reload)", :green)
|
|
62
62
|
end
|
|
63
63
|
say("App services were stopped, disabled and removed", :green)
|
|
64
64
|
|
|
@@ -105,44 +105,67 @@ module Procsd
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
desc "start", "Start app services"
|
|
108
|
-
def start
|
|
108
|
+
def start(service_name = nil)
|
|
109
109
|
preload!
|
|
110
110
|
say_target_not_exists and return unless target_exist?
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
say
|
|
112
|
+
if service_name
|
|
113
|
+
full_name = to_full_name(service_name)
|
|
114
|
+
say "Note: app service #{full_name} already started/active" if service_active?(full_name)
|
|
115
|
+
if execute %W(sudo systemctl start #{full_name} --all)
|
|
116
|
+
say("Started app service (#{full_name})", :green)
|
|
117
|
+
end
|
|
118
|
+
else
|
|
119
|
+
say "Note: app target #{target_name} already started/active" if target_active?
|
|
120
|
+
if execute %W(sudo systemctl start #{target_name})
|
|
121
|
+
say("Started app services (#{target_name})", :green)
|
|
122
|
+
end
|
|
115
123
|
end
|
|
116
124
|
end
|
|
117
125
|
|
|
118
126
|
desc "stop", "Stop app services"
|
|
119
|
-
def stop
|
|
127
|
+
def stop(service_name = nil)
|
|
120
128
|
preload!
|
|
121
129
|
say_target_not_exists and return unless target_exist?
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
say
|
|
131
|
+
if service_name
|
|
132
|
+
full_name = to_full_name(service_name)
|
|
133
|
+
say "Note: app service #{full_name} already stopped/inactive" if !service_active?(full_name)
|
|
134
|
+
if execute %W(sudo systemctl stop #{full_name} --all)
|
|
135
|
+
say("Stopped app service (#{full_name})", :green)
|
|
136
|
+
end
|
|
137
|
+
else
|
|
138
|
+
say "Note: app target #{target_name} already stopped/inactive" if !target_active?
|
|
139
|
+
if execute %W(sudo systemctl stop #{target_name})
|
|
140
|
+
say("Stopped app services (#{target_name})", :green)
|
|
141
|
+
end
|
|
126
142
|
end
|
|
127
143
|
end
|
|
128
144
|
|
|
129
145
|
desc "restart", "Restart app services"
|
|
130
|
-
def restart
|
|
146
|
+
def restart(service_name = nil)
|
|
131
147
|
preload!
|
|
132
148
|
say_target_not_exists and return unless target_exist?
|
|
133
149
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if has_reload?
|
|
139
|
-
execute %W(sudo systemctl reload-or-restart #{app_name}-* --all)
|
|
140
|
-
else
|
|
141
|
-
execute %W(sudo systemctl restart #{target_name})
|
|
150
|
+
if service_name
|
|
151
|
+
full_name = to_full_name(service_name)
|
|
152
|
+
if execute %W(sudo systemctl reload-or-restart #{full_name} --all)
|
|
153
|
+
say("Restarted app service (#{full_name})", :green)
|
|
142
154
|
end
|
|
155
|
+
else
|
|
156
|
+
# If one of the child services of a target has `ExecReload` and `ReloadPropagatedFrom`
|
|
157
|
+
# options defined, then use `reload-or-restart` to call all services (not the main target)
|
|
158
|
+
# because of systemd bug https://github.com/systemd/systemd/issues/10638
|
|
159
|
+
success =
|
|
160
|
+
if has_reload?
|
|
161
|
+
execute %W(sudo systemctl reload-or-restart #{app_name}-* --all)
|
|
162
|
+
else
|
|
163
|
+
execute %W(sudo systemctl restart #{target_name})
|
|
164
|
+
end
|
|
143
165
|
|
|
144
|
-
|
|
145
|
-
|
|
166
|
+
if success
|
|
167
|
+
say("Restarted app services (#{target_name})", :green)
|
|
168
|
+
end
|
|
146
169
|
end
|
|
147
170
|
end
|
|
148
171
|
|
|
@@ -159,7 +182,7 @@ module Procsd
|
|
|
159
182
|
command = %w(systemctl status --no-pager --output short-iso --all)
|
|
160
183
|
end
|
|
161
184
|
|
|
162
|
-
command << (options["target"] ? target_name :
|
|
185
|
+
command << (options["target"] ? target_name : to_full_name(service_name))
|
|
163
186
|
execute command, type: :exec
|
|
164
187
|
end
|
|
165
188
|
|
|
@@ -266,7 +289,7 @@ module Procsd
|
|
|
266
289
|
generator.generate_units(save: true)
|
|
267
290
|
|
|
268
291
|
if execute %w(sudo systemctl daemon-reload)
|
|
269
|
-
say("Reloaded
|
|
292
|
+
say("Reloaded configuration (daemon-reload)", :green)
|
|
270
293
|
end
|
|
271
294
|
|
|
272
295
|
enable
|
|
@@ -376,10 +399,18 @@ module Procsd
|
|
|
376
399
|
system "systemctl", "is-active", "--quiet", target_name
|
|
377
400
|
end
|
|
378
401
|
|
|
402
|
+
def service_active?(service_name)
|
|
403
|
+
system "systemctl", "is-active", "--quiet", service_name
|
|
404
|
+
end
|
|
405
|
+
|
|
379
406
|
def target_name
|
|
380
407
|
"#{app_name}.target"
|
|
381
408
|
end
|
|
382
409
|
|
|
410
|
+
def to_full_name(service_name)
|
|
411
|
+
"#{app_name}-#{service_name}*"
|
|
412
|
+
end
|
|
413
|
+
|
|
383
414
|
def app_name
|
|
384
415
|
@config[:app]
|
|
385
416
|
end
|
|
@@ -389,7 +420,7 @@ module Procsd
|
|
|
389
420
|
|
|
390
421
|
raise ConfigurationError, "Config file procsd.yml doesn't exists" unless File.exist? "procsd.yml"
|
|
391
422
|
begin
|
|
392
|
-
procsd = YAML.
|
|
423
|
+
procsd = YAML.safe_load(ERB.new(File.read "procsd.yml").result)
|
|
393
424
|
rescue => e
|
|
394
425
|
raise ConfigurationError, "Can't read procsd.yml: #{e.inspect}"
|
|
395
426
|
end
|
|
@@ -402,7 +433,7 @@ module Procsd
|
|
|
402
433
|
msg = "Procfile doesn't exists. Define processes in procsd.yml or create Procfile"
|
|
403
434
|
raise ConfigurationError, msg unless File.exist? "Procfile"
|
|
404
435
|
begin
|
|
405
|
-
procfile = YAML.
|
|
436
|
+
procfile = YAML.safe_load_file("Procfile")
|
|
406
437
|
rescue => e
|
|
407
438
|
raise ConfigurationError, "Can't read Procfile: #{e.inspect}"
|
|
408
439
|
end
|
data/lib/procsd/generator.rb
CHANGED
|
@@ -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,
|
|
102
|
+
ERB.new(content, trim_mode: "-").result(b)
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def write_file!(dest_path, content)
|
|
@@ -18,6 +18,10 @@ ExecStop=/bin/bash -lc '<%= stop %>'
|
|
|
18
18
|
ExecReload=/bin/bash -lc '<%= reload %>'
|
|
19
19
|
<% end -%>
|
|
20
20
|
|
|
21
|
+
<% if max_sec = config["commands"]["RuntimeMaxSec"] -%>
|
|
22
|
+
RuntimeMaxSec=<%= max_sec %>
|
|
23
|
+
<% end -%>
|
|
24
|
+
|
|
21
25
|
Restart=always
|
|
22
26
|
RestartSec=1
|
|
23
27
|
TimeoutStopSec=30
|
data/lib/procsd/version.rb
CHANGED
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.
|
|
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", "
|
|
31
|
-
spec.add_development_dependency "rake", "
|
|
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.
|
|
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:
|
|
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.
|
|
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:
|
|
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
|