nginx_stage 0.3.0 → 0.4.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: fa24a601f96e88b6ce80144643c1050d40610662
4
- data.tar.gz: c57cffe3cdd786e2871920b6867e0707e7a25864
3
+ metadata.gz: c9b3919f81c64e84a2280becde57f2d6aac9a346
4
+ data.tar.gz: 8f7677d4b45de1c348c3e03d7d0cf537415be9f7
5
5
  SHA512:
6
- metadata.gz: e139fd36c641d1a715afab850616b5aeb69d5a4241c06eb095317ee6007da4b5b2ed823a7637c2117b629be2ce7b7c007543b577813881e26931f5ff32bcf017
7
- data.tar.gz: 9e102f6f33a6b43bfb5bb5d5b354061e415cae2074472ae375fa78ec2e2dbd9ca9a9a57fb2d3a43fec6a6028df729c6428d789b7d51282a633703cb0cfc56cdb
6
+ metadata.gz: 2746bb855832210d40d2d62bc22a31b4270d8b535c54c168a7bfcfec0ec4b5bce1042edec794d8b54d9ded05d5cb56d7993b58be3901c2db000cc96ac3621d4c
7
+ data.tar.gz: c294a4171c99ef1b5acb3abf726fa9df3488b6d06faa6db286346675a2861799b1773c15dbd3d8f5c52936343a9ce01c0dc0afaf5cb37172fff94fc7d4475545
data/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2018-02-09
10
+ ### Added
11
+ - Added helpful utility for performing the necessary operations when updating
12
+ NGINX configs.
13
+
14
+ ### Changed
15
+ - Updated date in `LICENSE.txt`.
16
+
17
+ ## [0.3.2] - 2017-12-07
18
+ ### Changed
19
+ - Combined the Ruby wrapper script with the `nginx_stage` executable script.
20
+ [#27](https://github.com/OSC/nginx_stage/issues/27)
21
+
22
+ ### Fixed
23
+ - Display error if the user's home directory does not exist.
24
+ [#25](https://github.com/OSC/nginx_stage/issues/25)
25
+
26
+ ## [0.3.1] - 2017-11-27
27
+ ### Changed
28
+ - Replaced all occurrences of `Fixnum` with `Integer` to better support Ruby
29
+ 2.4+. [#29](https://github.com/OSC/nginx_stage/issues/29)
30
+
9
31
  ## [0.3.0] - 2017-10-30
10
32
  ### Added
11
33
  - Added a confirmation page when attempting to restart PUN due to discovery of
@@ -180,7 +202,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
180
202
  ### Added
181
203
  - Initial release
182
204
 
183
- [Unreleased]: https://github.com/OSC/nginx_stage/compare/v0.3.0...HEAD
205
+ [Unreleased]: https://github.com/OSC/nginx_stage/compare/v0.4.0...HEAD
206
+ [0.4.0]: https://github.com/OSC/nginx_stage/compare/v0.3.2...v0.4.0
207
+ [0.3.2]: https://github.com/OSC/nginx_stage/compare/v0.3.1...v0.3.2
208
+ [0.3.1]: https://github.com/OSC/nginx_stage/compare/v0.3.0...v0.3.1
184
209
  [0.3.0]: https://github.com/OSC/nginx_stage/compare/v0.2.1...v0.3.0
185
210
  [0.2.1]: https://github.com/OSC/nginx_stage/compare/v0.2.0...v0.2.1
186
211
  [0.2.0]: https://github.com/OSC/nginx_stage/compare/v0.1.0...v0.2.0
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016-2017 Ohio Supercomputer Center
1
+ Copyright (c) 2016-2018 Ohio Supercomputer Center
2
2
 
3
3
  MIT License
4
4
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ task :install => [:required_files] do
26
26
  end
27
27
 
28
28
  # Dynamically generate tasks for copying required files
29
- FileList['sbin/nginx_stage', 'bin/*', 'share/*', 'templates/*.erb', 'lib/**/*.rb'].each do |source|
29
+ FileList['sbin/*', 'bin/*', 'share/*', 'templates/*.erb', 'lib/**/*.rb'].each do |source|
30
30
  target = "#{PREFIX}/#{source}"
31
31
  file target => [source] do
32
32
  mkdir_p File.dirname(target) unless File.directory? File.dirname(target)
@@ -114,7 +114,7 @@ module NginxStage
114
114
 
115
115
  # Create an empty directory if it doesn't already exist
116
116
  # @param destination [String] the directory path
117
- # @param mode [Fixnum] the mode to set the directory as
117
+ # @param mode [Integer] the mode to set the directory as
118
118
  # @return [void]
119
119
  def empty_directory(destination, mode: 0755)
120
120
  FileUtils.mkdir_p destination, mode: mode
@@ -2,9 +2,8 @@ module NginxStage
2
2
  # Module that adds common options to generators.
3
3
  module GeneratorHelpers
4
4
  # Add support for accepting USER as an option
5
- # @param required [Boolean] whether user option is required
6
5
  # @return [void]
7
- def add_user_support(required: true)
6
+ def add_user_support
8
7
  # @!method user
9
8
  # The user that the per-user NGINX will run as
10
9
  # @return [User] the user of the nginx process
@@ -12,7 +11,7 @@ module NginxStage
12
11
  self.add_option :user do
13
12
  {
14
13
  opt_args: ["-u", "--user=USER", "# The USER of the per-user nginx process"],
15
- required: required,
14
+ required: true,
16
15
  before_init: -> (user) do
17
16
  raise InvalidUser, "invalid user name syntax: #{user}" unless user =~ NginxStage.user_regex
18
17
  user ? User.new(user) : nil
@@ -20,13 +19,18 @@ module NginxStage
20
19
  }
21
20
  end
22
21
 
23
- if required
24
- # Validate that the user isn't a special user (i.e., `root`)
25
- self.add_hook :validate_user_not_special do
26
- min_uid = NginxStage.min_uid
27
- if user.uid < min_uid
28
- raise InvalidUser, "user is special: #{user} (#{user.uid} < #{min_uid})"
29
- end
22
+ # Validate that the user isn't a special user (i.e., `root`)
23
+ self.add_hook :validate_user_not_special do
24
+ min_uid = NginxStage.min_uid
25
+ if user.uid < min_uid
26
+ raise InvalidUser, "user is special: #{user} (#{user.uid} < #{min_uid})"
27
+ end
28
+ end
29
+
30
+ # Validate that the user's home directory exists
31
+ self.add_hook :validate_user_has_home_dir do
32
+ unless Dir.exist?(user.dir)
33
+ raise InvalidUser, "home directory '#{user.dir}' does not exist for user: #{user}"
30
34
  end
31
35
  end
32
36
  end
@@ -6,10 +6,10 @@ module NginxStage
6
6
  attr_reader :pid_path
7
7
 
8
8
  # Process id that describes this object
9
- # @return [Fixnum] the pid object was initialized with
9
+ # @return [Integer] the pid object was initialized with
10
10
  attr_reader :pid
11
11
 
12
- # @param pid [Fixnum] the pid describing a process
12
+ # @param pid [Integer] the pid describing a process
13
13
  # @raise [MissingPidFile] if pid file doesn't exist in file system
14
14
  # @raise [InvalidPidFile] if it is an invalid pid file
15
15
  def initialize(pid_path)
@@ -16,7 +16,7 @@ module NginxStage
16
16
  end
17
17
 
18
18
  # The number of active sessions connected to this socket
19
- # @return [Fixnum] number of active connections
19
+ # @return [Integer] number of active connections
20
20
  def sessions
21
21
  # generate array of inodes
22
22
  ary_inodes = @processes.map{|h| h[:inode]}.reduce([], :+)
@@ -1,4 +1,4 @@
1
1
  module NginxStage
2
2
  # The current version of NginxStage
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
data/lib/nginx_stage.rb CHANGED
@@ -110,7 +110,7 @@ module NginxStage
110
110
 
111
111
  # Run Ruby block as a different user if possible
112
112
  # NB: Will forego user switching if current process is not root-owned
113
- # @param user [String, Fixnum, nil] the user or user id to switch to
113
+ # @param user [String, Integer, nil] the user or user id to switch to
114
114
  # @yield [] Block to run as given user
115
115
  def self.as_user(user, &block)
116
116
  (Process.uid == 0) && user ? sudo(user, &block) : block.call
@@ -119,7 +119,7 @@ module NginxStage
119
119
  private
120
120
  # Switch user/group effective id's as well as secondary groups
121
121
  def self.sudo(user, &block)
122
- passwd = (user.is_a? Fixnum) ? Etc.getpwuid(user) : Etc.getpwnam(user)
122
+ passwd = (user.is_a? Integer) ? Etc.getpwuid(user) : Etc.getpwnam(user)
123
123
  name, uid, gid = passwd.name, passwd.uid, passwd.gid
124
124
  Process.initgroups(name, gid)
125
125
  Process::GID.grant_privilege(gid)
data/sbin/nginx_stage CHANGED
@@ -1,7 +1,45 @@
1
- #!/opt/ood/nginx_stage/bin/ood_ruby
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ #!/usr/bin/env bash
3
2
 
4
- require 'nginx_stage'
3
+ # The purpose of this script is to wrap up the necessary environment for the
4
+ # per-user NGINX (PUN) processes to run under. The PUN requires the following
5
+ # software in its environment:
6
+ #
7
+ # - nginx 1.6
8
+ # - passenger 4.0
9
+ # - ruby 2.2
10
+ # - node.js 0.10
11
+ # - git 1.9
12
+ #
5
13
 
6
- # Start up the nginx_stage application
7
- NginxStage::Application.start
14
+ # Allow admin to override the environment the PUN runs in
15
+ #
16
+ NGINX_PROFILE=${NGINX_PROFILE:-/etc/ood/profile}
17
+ if [[ -f "${NGINX_PROFILE}" ]]; then
18
+ # Source in the custom environment
19
+ source "${NGINX_PROFILE}"
20
+ else
21
+ # For Software Collections 2.0
22
+ #
23
+ # 1. Read in environment variable SCL_PKGS which may be set in `sudo` call
24
+ # otherwise fallback to default software collection packages.
25
+ #
26
+ # 2. Check if Software Collections is installed, then source the defined
27
+ # package scripts.
28
+ #
29
+ SCL_PKGS=${SCL_PKGS:-"nginx16 rh-passenger40 rh-ruby22 nodejs010 git19"}
30
+ SCL_SOURCE="$(command -v scl_source)"
31
+ [[ "${SCL_SOURCE}" ]] && source "${SCL_SOURCE}" enable ${SCL_PKGS}
32
+ fi
33
+
34
+ # Root directory for this library
35
+ #
36
+ ROOT_DIR="$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")"
37
+
38
+ # Environment is set, so call Ruby now
39
+ #
40
+ exec \
41
+ /usr/bin/env ruby \
42
+ -I"${ROOT_DIR}/lib" \
43
+ -rnginx_stage \
44
+ -e "NginxStage::Application.start" \
45
+ -- "${@}"
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ROOT="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
4
+
5
+ CONFIG="${CONFIG:-/etc/ood/config/nginx_stage.yml}"
6
+ BIN="${BIN:-${ROOT}/nginx_stage}"
7
+
8
+ set -e
9
+
10
+ OPTS=$(getopt -o q --long quiet -n 'update_nginx_stage' -- "${@}")
11
+ eval set -- "${OPTS}"
12
+ while true; do
13
+ case "${1}" in
14
+ -q | --quiet ) QUIET=true; shift ;;
15
+ -- ) shift; break ;;
16
+ * ) break ;;
17
+ esac
18
+ done
19
+
20
+ if [[ "${QUIET}" == "true" ]]; then
21
+ exec > /dev/null
22
+ fi
23
+
24
+ echo "Updating NGINX configs using YAML config: '${CONFIG}'"
25
+
26
+ export NGINX_STAGE_CONFIG_FILE="${CONFIG}"
27
+ if [[ "${QUIET}" != "true" ]]; then
28
+ set -x
29
+ fi
30
+ "${BIN}" app_clean
31
+ "${BIN}" app_reset --sub-uri=/pun
32
+ "${BIN}" nginx_clean
33
+ { set +x; } 2>/dev/null
34
+
35
+ echo "Completed successfully!"
36
+ echo ""
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.3.0
4
+ version: 0.4.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: 2017-10-30 00:00:00.000000000 Z
11
+ date: 2018-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,7 +58,6 @@ email:
58
58
  - jnicklas@osc.edu
59
59
  executables:
60
60
  - node
61
- - ood_ruby
62
61
  - python
63
62
  - ruby
64
63
  extensions: []
@@ -72,7 +71,6 @@ files:
72
71
  - README.md
73
72
  - Rakefile
74
73
  - bin/node
75
- - bin/ood_ruby
76
74
  - bin/python
77
75
  - bin/ruby
78
76
  - lib/nginx_stage.rb
@@ -98,6 +96,7 @@ files:
98
96
  - lib/nginx_stage/views/pun_config_view.rb
99
97
  - nginx_stage.gemspec
100
98
  - sbin/nginx_stage
99
+ - sbin/update_nginx_stage
101
100
  - share/nginx_stage_example.yml
102
101
  - templates/app.conf.erb
103
102
  - templates/pun.conf.erb
data/bin/ood_ruby DELETED
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # Open OnDemand Ruby wrapper script
4
- #
5
- # The purpose of this script is to wrap up the necessary environment for the
6
- # per-user NGINX (PUN) processes to run under. The PUN requires the following
7
- # software in its environment:
8
- #
9
- # - nginx 1.6
10
- # - passenger 4.0
11
- # - ruby 2.2
12
- # - node.js 0.10
13
- # - git 1.9
14
- #
15
-
16
- # Allow admin to override the environment the PUN runs in
17
- #
18
- NGINX_PROFILE=${NGINX_PROFILE:-/etc/ood/profile}
19
- if [[ -f "${NGINX_PROFILE}" ]]; then
20
- # Source in the custom environment
21
- source "${NGINX_PROFILE}"
22
- else
23
- # For Software Collections 2.0
24
- #
25
- # 1. Read in environment variable SCL_PKGS which may be set in `sudo` call
26
- # otherwise fallback to default software collection packages.
27
- #
28
- # 2. Check if Software Collections is installed, then source the defined
29
- # package scripts.
30
- #
31
- SCL_PKGS=${SCL_PKGS:-"nginx16 rh-passenger40 rh-ruby22 nodejs010 git19"}
32
- SCL_SOURCE="$(command -v scl_source)"
33
- [[ ${SCL_SOURCE} ]] && source "${SCL_SOURCE}" enable ${SCL_PKGS}
34
- fi
35
-
36
- # Environment is set, so call Ruby now
37
- #
38
- exec /usr/bin/env ruby "$@"