3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/port_map/nginx.rb', line 3
def self.conf_directory
return ENV.fetch('NGINX_DIR') if ENV.key?('NGINX_DIR')
_, stdout, stderr = Open3.popen3('nginx -t')
location_match = [stdout.read, stderr.read].join.match(/nginx: the configuration file (.+?) syntax/)
if location_match && !location_match.captures.empty?
Pathname.new(location_match.captures.first).dirname.to_s
else
raise '`nginx -t` command did not reveal nginx conf. You can set NGINX_DIR environment variable to indicate nginx conf directory'
end
end
|