nginx_stage 0.4.0 → 0.5.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
  SHA1:
3
- metadata.gz: c9b3919f81c64e84a2280becde57f2d6aac9a346
4
- data.tar.gz: 8f7677d4b45de1c348c3e03d7d0cf537415be9f7
3
+ metadata.gz: 119f019f0d50000e6eca41b3464f2971345be084
4
+ data.tar.gz: a19e78dbfdc7dbb2af510cfa3117b8b74e00f795
5
5
  SHA512:
6
- metadata.gz: 2746bb855832210d40d2d62bc22a31b4270d8b535c54c168a7bfcfec0ec4b5bce1042edec794d8b54d9ded05d5cb56d7993b58be3901c2db000cc96ac3621d4c
7
- data.tar.gz: c294a4171c99ef1b5acb3abf726fa9df3488b6d06faa6db286346675a2861799b1773c15dbd3d8f5c52936343a9ce01c0dc0afaf5cb37172fff94fc7d4475545
6
+ metadata.gz: e79f39728628cec8cbc7936adeab22fa00912ce665a51a45e33607be053eaa84a13cefcf05537c80b6ff80d25918dae448bd2ad850345dad48db378f637a342e
7
+ data.tar.gz: c103c842dbb5e79e735cac641d229e1f3e36be42820cc51907cef7e46110d61d2bb3cc4854c713bb0e1c738c923b1220d5b70b45fce783cae5b08fbe8f57ba98
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.5.0] - 2018-04-30
10
+ ### Added
11
+ - Made currently installed version number of OnDemand available to all PUNs if
12
+ the OnDemand version file exists.
13
+ [#36](https://github.com/OSC/nginx_stage/issues/36)
14
+ - Can specify portal name to namespace multiple OnDemand hosted portals.
15
+ [#33](https://github.com/OSC/nginx_stage/issues/33)
16
+ - Can specify portal title for apps to use in their views.
17
+ [#33](https://github.com/OSC/nginx_stage/issues/33)
18
+
9
19
  ## [0.4.0] - 2018-02-09
10
20
  ### Added
11
21
  - Added helpful utility for performing the necessary operations when updating
@@ -202,7 +212,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
202
212
  ### Added
203
213
  - Initial release
204
214
 
205
- [Unreleased]: https://github.com/OSC/nginx_stage/compare/v0.4.0...HEAD
215
+ [Unreleased]: https://github.com/OSC/nginx_stage/compare/v0.5.0...HEAD
216
+ [0.5.0]: https://github.com/OSC/nginx_stage/compare/v0.4.0...v0.5.0
206
217
  [0.4.0]: https://github.com/OSC/nginx_stage/compare/v0.3.2...v0.4.0
207
218
  [0.3.2]: https://github.com/OSC/nginx_stage/compare/v0.3.1...v0.3.2
208
219
  [0.3.1]: https://github.com/OSC/nginx_stage/compare/v0.3.0...v0.3.1
data/lib/nginx_stage.rb CHANGED
@@ -36,6 +36,50 @@ module NginxStage
36
36
 
37
37
  extend Configuration
38
38
 
39
+ # The current version of OnDemand installed
40
+ # @example Get version of OnDemand for version file that exists
41
+ # ondemand_version #=> "1.3.0"
42
+ # @example No version file exists
43
+ # ondemand_version #=> nil
44
+ # @return [String, nil] current version of installed OnDemand if exists
45
+ def self.ondemand_version
46
+ version = File.read(ondemand_version_path).strip
47
+ version.empty? ? nil : version
48
+ rescue
49
+ nil
50
+ end
51
+
52
+ # The unique name of the hosted OnDemand portal used to namespace apps, their
53
+ # data, and logging information
54
+ # @example No OnDemand Portal name specified
55
+ # portal #=> "ondemand"
56
+ # @example The AweSim portal is specified
57
+ # portal #=> "awesim"
58
+ # @return [String] unique portal name
59
+ def self.portal
60
+ portal = ondemand_portal.to_s.strip
61
+ if portal.empty?
62
+ "ondemand"
63
+ else
64
+ portal.downcase.gsub(/\s+/, "_")
65
+ end
66
+ end
67
+
68
+ # The title of the hosted OnDemand portal
69
+ # @example No title supplied
70
+ # title #=> "Open OnDemand"
71
+ # @example The OSC OnDemand portal
72
+ # title #=> "OSC OnDemand"
73
+ # @return [String] portal title
74
+ def self.title
75
+ title = ondemand_title.to_s.strip
76
+ if title.empty?
77
+ "Open OnDemand"
78
+ else
79
+ title
80
+ end
81
+ end
82
+
39
83
  # Regex used to parse an app request
40
84
  # @example Dev app request
41
85
  # parse_app_request(request: '/dev/rails1/structure/1')
@@ -59,6 +103,24 @@ module NginxStage
59
103
  app_info
60
104
  end
61
105
 
106
+ # Environment used during execution of nginx binary
107
+ # @example Start the per-user NGINX for user Bob
108
+ # nginx_env(user: 'bob')
109
+ # #=> { "USER" => "bob", ... }
110
+ # @param user [String] the owner of the nginx process
111
+ # @return [Hash{String=>String}] the environment used to execute the nginx process
112
+ def self.nginx_env(user:)
113
+ {
114
+ "USER" => user,
115
+ "ONDEMAND_VERSION" => ondemand_version,
116
+ "ONDEMAND_PORTAL" => portal,
117
+ "ONDEMAND_TITLE" => title,
118
+ # backwards compatibility
119
+ "OOD_PORTAL" => ondemand_portal,
120
+ "OOD_DASHBOARD_TITLE" => ondemand_title,
121
+ }
122
+ end
123
+
62
124
  # Arguments used during execution of nginx binary
63
125
  # @example Start the per-user NGINX for user Bob
64
126
  # nginx_args(user: 'bob')
@@ -8,6 +8,19 @@ module NginxStage
8
8
  # Global
9
9
  #
10
10
 
11
+ # Path to the OnDemand version file that contains version of OnDemand
12
+ # installed
13
+ # @return [String] the ondemand version file
14
+ attr_accessor :ondemand_version_path
15
+
16
+ # Unique name of OnDemand portal for namespacing multiple portals
17
+ # @return [String, nil] the name of OnDemand portal if defined
18
+ attr_accessor :ondemand_portal
19
+
20
+ # Title of the OnDemand portal that apps *should* display in their navbar
21
+ # @return [String, nil] the title of the Dashboard if defined
22
+ attr_accessor :ondemand_title
23
+
11
24
  # Location of ERB templates used as NGINX configs
12
25
  # @return [String] the ERB templates root path
13
26
  attr_accessor :template_root
@@ -202,7 +215,7 @@ module NginxStage
202
215
  File.expand_path(
203
216
  @app_root.fetch(env) do
204
217
  raise InvalidRequest, "invalid request environment: #{env}"
205
- end % {env: env, owner: owner, name: name}
218
+ end % {env: env, owner: owner, name: name, portal: portal}
206
219
  )
207
220
  end
208
221
 
@@ -330,7 +343,10 @@ module NginxStage
330
343
  # Sets the default configuration options
331
344
  # @return [void]
332
345
  def set_default_configuration
333
- self.template_root = "#{root}/templates"
346
+ self.ondemand_version_path = "/opt/ood/VERSION"
347
+ self.ondemand_portal = nil
348
+ self.ondemand_title = nil
349
+ self.template_root = "#{root}/templates"
334
350
 
335
351
  self.proxy_user = 'apache'
336
352
  self.nginx_bin = '/opt/rh/nginx16/root/usr/sbin/nginx'
@@ -361,7 +377,7 @@ module NginxStage
361
377
  sys: '/var/lib/nginx/config/apps/sys/%{name}.conf'
362
378
  }
363
379
  self.app_root = {
364
- dev: '~%{owner}/ondemand/dev/%{name}',
380
+ dev: '~%{owner}/%{portal}/dev/%{name}',
365
381
  usr: '/var/www/ood/apps/usr/%{owner}/gateway/%{name}',
366
382
  sys: '/var/www/ood/apps/sys/%{name}'
367
383
  }
@@ -79,10 +79,24 @@ module NginxStage
79
79
  add_hook :exec_nginx do
80
80
  if !skip_nginx
81
81
  if File.file? NginxStage.pun_pid_path(user: user)
82
- o, s = Open3.capture2e([NginxStage.nginx_bin, "(#{user})"], *NginxStage.nginx_args(user: user, signal: :stop))
82
+ o, s = Open3.capture2e(
83
+ NginxStage.nginx_env(user: user),
84
+ [
85
+ NginxStage.nginx_bin,
86
+ "(#{user})"
87
+ ],
88
+ *NginxStage.nginx_args(user: user, signal: :stop)
89
+ )
83
90
  abort(o) unless s.success?
84
91
  end
85
- o, s = Open3.capture2e([NginxStage.nginx_bin, "(#{user})"], *NginxStage.nginx_args(user: user))
92
+ o, s = Open3.capture2e(
93
+ NginxStage.nginx_env(user: user),
94
+ [
95
+ NginxStage.nginx_bin,
96
+ "(#{user})"
97
+ ],
98
+ *NginxStage.nginx_args(user: user)
99
+ )
86
100
  s.success? ? exit : abort(o)
87
101
  end
88
102
  end
@@ -48,7 +48,11 @@ module NginxStage
48
48
  if socket.sessions.zero? || force
49
49
  puts u
50
50
  if !skip_nginx
51
- o, s = Open3.capture2e(NginxStage.nginx_bin, *NginxStage.nginx_args(user: u, signal: :stop))
51
+ o, s = Open3.capture2e(
52
+ NginxStage.nginx_env(user: u),
53
+ NginxStage.nginx_bin,
54
+ *NginxStage.nginx_args(user: u, signal: :stop)
55
+ )
52
56
  $stderr.puts o unless s.success?
53
57
  end
54
58
  end
@@ -34,7 +34,14 @@ module NginxStage
34
34
  # Run the per-user NGINX process (exit quietly on success)
35
35
  add_hook :exec_nginx do
36
36
  if !skip_nginx
37
- o, s = Open3.capture2e([NginxStage.nginx_bin, "(#{user})"], *NginxStage.nginx_args(user: user, signal: signal))
37
+ o, s = Open3.capture2e(
38
+ NginxStage.nginx_env(user: user),
39
+ [
40
+ NginxStage.nginx_bin,
41
+ "(#{user})"
42
+ ],
43
+ *NginxStage.nginx_args(user: user, signal: signal)
44
+ )
38
45
  s.success? ? exit : abort(o)
39
46
  end
40
47
  end
@@ -82,7 +82,14 @@ module NginxStage
82
82
  # Run the per-user NGINX process (exit quietly on success)
83
83
  add_hook :exec_nginx do
84
84
  if !skip_nginx
85
- o, s = Open3.capture2e([NginxStage.nginx_bin, "(#{user})"], *NginxStage.nginx_args(user: user))
85
+ o, s = Open3.capture2e(
86
+ NginxStage.nginx_env(user: user),
87
+ [
88
+ NginxStage.nginx_bin,
89
+ "(#{user})"
90
+ ],
91
+ *NginxStage.nginx_args(user: user)
92
+ )
86
93
  s.success? ? exit : abort(o)
87
94
  end
88
95
  end
@@ -1,4 +1,4 @@
1
1
  module NginxStage
2
2
  # The current version of NginxStage
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
@@ -14,6 +14,20 @@
14
14
 
15
15
  ---
16
16
 
17
+ # Path to the OnDemand version file
18
+ #
19
+ #ondemand_version_path: '/opt/ood/VERSION'
20
+
21
+ # Unique name of this OnDemand portal used to namespace multiple hosted portals
22
+ # NB: If this is not set then most apps will use default namespace "ondemand"
23
+ #
24
+ #ondemand_portal: null
25
+ #
26
+ # Title of this OnDemand portal that apps *should* display in their navbar
27
+ # NB: If this is not set then most apps will use default title "Open OnDemand"
28
+ #
29
+ #ondemand_title: null
30
+
17
31
  # Location of the ERB templates used in the generation of the NGINX configs
18
32
  #
19
33
  #template_root: '/opt/ood/nginx_stage/templates'
@@ -115,7 +129,7 @@
115
129
  # corresponding environment
116
130
  #
117
131
  #app_root:
118
- # dev: '~%{owner}/ondemand/dev/%{name}'
132
+ # dev: '~%{owner}/%{portal}/dev/%{name}'
119
133
  # usr: '/var/www/ood/apps/usr/%{owner}/gateway/%{name}'
120
134
  # sys: '/var/www/ood/apps/sys/%{name}'
121
135
 
@@ -1,6 +1,3 @@
1
- # Setup environment
2
- env USER=<%= user %>;
3
-
4
1
  user <%= user %> <%= group %>; ## Default: nobody
5
2
  error_log <%= error_log_path %>;
6
3
  pid <%= pid_path %>;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nginx_stage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Nicklas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-09 00:00:00.000000000 Z
11
+ date: 2018-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.4.5
125
+ rubygems_version: 2.4.5.4
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Stage and control per-user NGINX processes.