procsd 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8e46fcf465ed019b9ec9e9c77466ac959c0cc478e57f29d0b0dfcedf936ddfd
4
- data.tar.gz: c7ba7690a99bde57f8c16512ba052a52d6da64f83619a33970a3fcddf48a65e9
3
+ metadata.gz: 417ecd3b90ef7fe2c1c1b9194db6cf90a3ca9af0be6ea2807b875d2323a36122
4
+ data.tar.gz: 4684afccd53e642bbc21ab45a7432e6a39b5ecab9839f9bd79c2cb0c226cf1fd
5
5
  SHA512:
6
- metadata.gz: 16d5b9e1ff29bfcedbfe29e0f455b289e527f5cbb1ef4e14a0de2e7c677d30ed00c1584264293ea35ca123ce7d74045403bcf2f09926268d234c7e5f6590fe2e
7
- data.tar.gz: 1c554a1804e6bfdab700808dd31b9dbc5ac88ff041ad6eda1f3be17edcd16542bc3502596509c5704b9225d8aba3cd5c6f718c7dcc577143ed032dcc189d4c6d
6
+ metadata.gz: 138c52b892a4e5afd53610a00082842b5db62c221c57820ffbb766d1fd91a5d5b9015b1248dd529ffbc27f75d68bf7c534158c32a38c23e82b45eac3f3ca14b3
7
+ data.tar.gz: 8caaae341c22e986466cc28173f0fb0a35f40f1d74d25af7a78ebb6af3cdfa20ab0110dece121602ddb3bf4989b6f64d197000509afb2b5b731bcd49c28f1da3
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.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).
11
+ > **Note:** latest version of Procsd is `0.5.2`. 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
 
@@ -64,7 +64,7 @@ You can provide additional options for `create` command:
64
64
  * `--dir` - application's working directory, default is current _$PWD_ env variable
65
65
  * `--path` - $PATH to include to the each service. Default is current _$PATH_ env variable
66
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.
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.
68
68
 
69
69
 
70
70
  ### Start application
@@ -192,7 +192,7 @@ Systemd provides [a lot of possibilities](https://www.digitalocean.com/community
192
192
  Currently, procsd can not run all processes in development like `foreman start` does. But you can run one single process using `procsd exec` command:
193
193
 
194
194
  ```
195
- deploy@server:~/sample_app$ PORT=3000 procsd exec web
195
+ deploy@server:~/sample_app$ procsd exec web
196
196
 
197
197
  => Booting Puma
198
198
  => Rails 5.2.1 application starting in development
@@ -205,12 +205,30 @@ Puma starting in single mode...
205
205
  Use Ctrl-C to stop
206
206
  ```
207
207
 
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`.
208
+ `procsd exec` requres all the environment variables defined in `environment` section of `procsd.yml` config file. 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:
209
+
210
+ ```yaml
211
+ app: sample_app
212
+ environment:
213
+ PORT: 2501
214
+ RAILS_ENV: production
215
+ RAILS_LOG_TO_STDOUT: true
216
+ dev_environment:
217
+ RAILS_ENV: development
218
+ SOME_OTHER_DEV_ENV_VARIABLE=value
219
+ ```
220
+
221
+ ```
222
+ deploy@server:~/sample_app$ PORT=3000 procsd exec web --dev
223
+ ```
224
+
225
+ > The web process runs with all environment & dev_environment variables required.
226
+
209
227
 
210
228
  ### Nginx integration (with automatic HTTPS)
211
229
  > Before make sure that you have Nginx installed `sudo apt install nginx` and running `sudo systemctl status nginx`.
212
230
 
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).
231
+ 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).
214
232
 
215
233
  Add to your procsd.yml `nginx` section with `server_name` option defined:
216
234
 
@@ -218,7 +236,7 @@ Add to your procsd.yml `nginx` section with `server_name` option defined:
218
236
 
219
237
  > 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
238
 
221
- ```yml
239
+ ```yaml
222
240
  app: sample_app
223
241
  processes:
224
242
  web: bundle exec rails server -p $PORT
@@ -231,6 +249,7 @@ environment:
231
249
  RAILS_LOG_TO_STDOUT: true
232
250
  nginx:
233
251
  server_name: my-domain.com
252
+ public_folder_path: public # path is relative to the main project directory, not required, default value is `public`.
234
253
  ```
235
254
 
236
255
  Configuration is done! Run [procsd create](#create-an-application-export-to-systemd) to create app services with Nginx reverse proxy config:
@@ -257,7 +276,7 @@ Nginx config created and daemon reloaded
257
276
  <summary>/etc/nginx/sites-available/sample_app</summary>
258
277
 
259
278
  ```
260
- upstream app {
279
+ upstream sample_app {
261
280
  server 127.0.0.1:2501;
262
281
  }
263
282
 
@@ -274,14 +293,14 @@ server {
274
293
  add_header Cache-Control public;
275
294
  }
276
295
 
277
- try_files $uri/index.html $uri @app;
278
- location @app {
296
+ try_files $uri/index.html $uri @sample_app;
297
+ location @sample_app {
279
298
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
280
299
  proxy_set_header Host $http_host;
281
300
  proxy_set_header X-Forwarded-Proto $scheme;
282
301
  proxy_set_header X-Real-IP $remote_addr;
283
302
  proxy_redirect off;
284
- proxy_pass http://app;
303
+ proxy_pass http://sample_app;
285
304
  }
286
305
 
287
306
  client_max_body_size 256M;
@@ -460,7 +479,6 @@ https://github.com/vifreefly/capistrano-procsd
460
479
 
461
480
  ## ToDo
462
481
  * 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`)
463
- * Add integration with [Inspeqtor](https://github.com/mperham/inspeqtor) to monitor application services and get alert notifications if something happened
464
482
 
465
483
 
466
484
  ## License
@@ -18,12 +18,16 @@ module Procsd
18
18
  preload!
19
19
  if @config[:nginx]
20
20
  raise ConfigurationError, "Can't find nginx executable available" unless in_path?("nginx")
21
- unless Dir.exist?(File.join options["dir"], "public")
21
+
22
+ public_folder_path = @config[:nginx]["public_folder_path"] || "public"
23
+ unless Dir.exist?(File.join options["dir"], public_folder_path)
22
24
  raise ConfigurationError, "Missing public/ folder to use with Nginx"
23
25
  end
26
+
24
27
  unless @config.dig(:environment, "PORT")
25
28
  raise ConfigurationError, "Please provide PORT environment variable in procsd.yml to use with Nginx"
26
29
  end
30
+
27
31
  if @config[:nginx]["ssl"]
28
32
  raise ConfigurationError, "Can't find certbot executable available" unless in_path?("certbot")
29
33
  end
@@ -202,19 +206,20 @@ module Procsd
202
206
 
203
207
  map exec: :__exec
204
208
  desc "exec", "Run app process"
205
- option :env, type: :boolean, banner: "Require environment defined in procsd.yml"
209
+ option :dev, type: :boolean, banner: "Require dev_environment (in additional to base env) defined in procsd.yml"
206
210
  def __exec(process_name)
207
211
  preload!
208
212
 
209
213
  start_cmd = @config[:processes].dig(process_name, "commands", "ExecStart")
210
214
  raise ArgumentError, "Process is not defined: #{process_name}" unless start_cmd
211
215
 
212
- if options["env"]
213
- @config[:environment].each { |k, v| @config[:environment][k] = v.to_s }
214
- exec @config[:environment], start_cmd
215
- else
216
- exec start_cmd
216
+ process_env = @config[:environment].each { |k, v| @config[:environment][k] = v.to_s }
217
+ if options["dev"]
218
+ dev_env = @config[:dev_environment].each { |k, v| @config[:dev_environment][k] = v.to_s }
219
+ process_env.merge!(dev_env)
217
220
  end
221
+
222
+ exec process_env, start_cmd
218
223
  end
219
224
 
220
225
  map %w[--version -v] => :__print_version
@@ -397,6 +402,8 @@ module Procsd
397
402
  end
398
403
 
399
404
  @config[:environment] = procsd["environment"] || {}
405
+ @config[:dev_environment] = procsd["dev_environment"] || {}
406
+
400
407
  @config[:systemd_dir] = procsd["systemd_dir"] || DEFAULT_SYSTEMD_DIR
401
408
  @config[:nginx] = procsd["nginx"]
402
409
  end
@@ -68,8 +68,11 @@ module Procsd
68
68
  end
69
69
 
70
70
  def generate_nginx_conf(save: false)
71
- root_path = File.join(@options["dir"], "public")
71
+ public_folder_path = @config[:nginx]["public_folder_path"] || "public"
72
+ root_path = File.join(@options["dir"], public_folder_path)
73
+
72
74
  content = generate_template("nginx", {
75
+ app_name: @config[:app],
73
76
  port: @config[:environment]["PORT"],
74
77
  server_name: @config[:nginx]["server_name"],
75
78
  root: root_path,
@@ -1,4 +1,4 @@
1
- upstream app {
1
+ upstream <%= config[:app_name] %> {
2
2
  server 127.0.0.1:<%= config[:port] %>;
3
3
  }
4
4
 
@@ -15,14 +15,14 @@ server {
15
15
  add_header Cache-Control public;
16
16
  }
17
17
 
18
- try_files $uri/index.html $uri @app;
19
- location @app {
18
+ try_files $uri/index.html $uri @<%= config[:app_name] %>;
19
+ location @<%= config[:app_name] %> {
20
20
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21
21
  proxy_set_header Host $http_host;
22
22
  proxy_set_header X-Forwarded-Proto $scheme;
23
23
  proxy_set_header X-Real-IP $remote_addr;
24
24
  proxy_redirect off;
25
- proxy_pass http://app;
25
+ proxy_pass http://<%= config[:app_name] %>;
26
26
  }
27
27
 
28
28
  client_max_body_size 256M;
@@ -1,3 +1,3 @@
1
1
  module Procsd
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
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.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Afanasev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-17 00:00:00.000000000 Z
11
+ date: 2020-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -124,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.7.6
127
+ rubygems_version: 3.1.2
129
128
  signing_key:
130
129
  specification_version: 4
131
130
  summary: Manage your application processes in production hassle-free like Heroku CLI