procsd 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +17 -4
- data/lib/procsd/cli.rb +51 -20
- data/lib/procsd/templates/service.erb +4 -0
- 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: 595c0d49250c7eb5075f7c01b7e6f28814bdc319cca686ad0ee0b5a5cea09c28
|
4
|
+
data.tar.gz: de7f7d1df76a9ec2cfdb7c55a90ca87c89fcb387afb28addd52734f42bcf2193
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c410272886ffe376089154a6499ccb9da9634732b01b8c84c45627e6a3c5ff73b47106c6680095a3529f01d3f94ab928828c882a50b8f39e5164004063c14bae
|
7
|
+
data.tar.gz: 6d9d84f9fd041b28a543dad0d458a5feed9ac0867062a82cd2af7926adda5d2e91be0162f972154b87cbb51442f1c49aadfb76dee30932406e593648568e0207
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# CHANGELOG
|
2
|
+
## 0.5.5
|
3
|
+
* Add: Allow to start/stop/restart particular service in the app target (example: `$ procsd start web`)
|
4
|
+
* Add: RuntimeMaxSec option for process
|
5
|
+
|
2
6
|
## 0.5.4
|
3
7
|
* Add: information how to use SSL integration with Cloudflare CDN enabled
|
4
8
|
* Add: procsd config certbot_command command
|
data/README.md
CHANGED
@@ -70,13 +70,14 @@ You can provide additional options for `create` command:
|
|
70
70
|
### Start application
|
71
71
|
> Other control commands: `stop` and `restart`
|
72
72
|
|
73
|
+
> You can start/stop/restart a particular process by providing it's name, i.e.: `$ procsd restart worker`
|
74
|
+
|
73
75
|
```
|
74
76
|
deploy@server:~/sample_app$ procsd start
|
75
77
|
|
76
78
|
Started app services (sample_app.target)
|
77
79
|
```
|
78
80
|
|
79
|
-
|
80
81
|
### Check the status
|
81
82
|
> 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
83
|
|
@@ -320,7 +321,7 @@ Everything is done. Start app services (`procsd start`) and go to `http://my-dom
|
|
320
321
|
|
321
322
|
#### Auto SSL using Certbot
|
322
323
|
|
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:
|
324
|
+
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
325
|
|
325
326
|
```bash
|
326
327
|
$ sudo apt install software-properties-common
|
@@ -519,9 +520,9 @@ Execute: journalctl --no-pager --no-hostname --all --output short-iso -n 3 --uni
|
|
519
520
|
|
520
521
|
* You can use extended format of processes commands inside `procsd.yml` to provide additional restart/stop commands for each process:
|
521
522
|
|
522
|
-
> All possible options:
|
523
|
+
> 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
524
|
|
524
|
-
> If procsd.yml has `processes:` option defined, then content of Procfile will be ignored
|
525
|
+
> If procsd.yml has `processes:` option defined, then content of Procfile (if it exists) will be ignored.
|
525
526
|
|
526
527
|
```yml
|
527
528
|
app: sample_app
|
@@ -534,6 +535,18 @@ processes:
|
|
534
535
|
|
535
536
|
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
537
|
|
538
|
+
* 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:
|
539
|
+
|
540
|
+
> Example values for RuntimeMaxSec: `30s` (30 seconds), `5m` (5 minutes), `3h` (3 hours), `1d` (1 day).
|
541
|
+
|
542
|
+
```yml
|
543
|
+
app: sample_app
|
544
|
+
processes:
|
545
|
+
web:
|
546
|
+
ExecStart: bundle exec rails server -p $PORT
|
547
|
+
RuntimeMaxSec: 12h
|
548
|
+
```
|
549
|
+
|
537
550
|
* 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
551
|
|
539
552
|
|
data/lib/procsd/cli.rb
CHANGED
@@ -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
|
|
@@ -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
|
@@ -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
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.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Afanasev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|