Enable dynamic creation of uwsgi pyargv option
Specifying hard-coded config files via the uwsgi pyargv option caused failures when a file didn't exist. This patch enables dynamic creation of the pyargv option. If an OpenStack config file doesn't exist, it won't be addeded to pyargv. Change-Id: I1d0fae42b2e43fe8808fda3de83e122502233a4c
This commit is contained in:
parent
59ae1061be
commit
7cce7bdc1b
|
@ -190,16 +190,46 @@ class OpenStackSnap(object):
|
|||
cmd = ["{snap}/bin/uwsgi".format(**utils.snap_env)]
|
||||
defaults = [d.format(**utils.snap_env) for d in DEFAULT_UWSGI_ARGS]
|
||||
cmd.extend(defaults)
|
||||
pyargv = []
|
||||
|
||||
uwsgi_dir = entry_point.get('uwsgi-dir')
|
||||
if uwsgi_dir:
|
||||
uwsgi_dir = uwsgi_dir.format(**utils.snap_env)
|
||||
cmd.append(uwsgi_dir)
|
||||
|
||||
uwsgi_log = entry_point.get('uwsgi-log')
|
||||
if uwsgi_log:
|
||||
uwsgi_log = uwsgi_log.format(**utils.snap_env)
|
||||
cmd.extend(['--logto', uwsgi_log])
|
||||
|
||||
for cfile in entry_point.get('config-files', []):
|
||||
cfile = cfile.format(**utils.snap_env)
|
||||
if os.path.exists(cfile):
|
||||
pyargv.append('--config-file={}'.format(cfile))
|
||||
else:
|
||||
LOG.debug('Configuration file {} not found'
|
||||
', skipping'.format(cfile))
|
||||
|
||||
for cdir in entry_point.get('config-dirs', []):
|
||||
cdir = cdir.format(**utils.snap_env)
|
||||
if os.path.exists(cdir):
|
||||
pyargv.append('--config-dir={}'.format(cdir))
|
||||
else:
|
||||
LOG.debug('Configuration directory {} not found'
|
||||
', skipping'.format(cdir))
|
||||
|
||||
log_file = entry_point.get('log-file')
|
||||
if log_file:
|
||||
log_file = log_file.format(**utils.snap_env)
|
||||
cmd.extend(['--logto', log_file])
|
||||
pyargv.append('--log-file={}'.format(log_file))
|
||||
|
||||
for uwsgi_cfile in os.listdir(uwsgi_dir):
|
||||
uwsgi_cfile = os.path.join(uwsgi_dir, uwsgi_cfile)
|
||||
with open(uwsgi_cfile, 'a+') as cf:
|
||||
if 'pyargv' not in cf:
|
||||
LOG.debug('Appending pyargv option to {}, pyargv = '
|
||||
'{}'.format(uwsgi_cfile, ' '.join(pyargv)))
|
||||
cf.write('\npyargv = {}'.format(' '.join(pyargv)))
|
||||
|
||||
elif cmd_type == NGINX_EP_TYPE:
|
||||
cmd = ["{snap}/usr/sbin/nginx".format(**utils.snap_env)]
|
||||
|
|
|
@ -28,7 +28,12 @@ entry_points:
|
|||
keystone-uwsgi:
|
||||
type: uwsgi
|
||||
uwsgi-dir: "/etc/uwsgi"
|
||||
log-file: "/var/log/uwsgi/keystone.log"
|
||||
uwsgi-log: "/var/log/uwsgi/keystone.log"
|
||||
config-files:
|
||||
- "/etc/keystone/keystone.conf"
|
||||
config-dirs:
|
||||
- "/etc/keystone/conf.d"
|
||||
log-file: "/var/log/keystone/keystone.log"
|
||||
run_as:
|
||||
keystone: [keystone]
|
||||
keystone-nginx:
|
||||
|
|
Loading…
Reference in New Issue