1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

gunicorn - minor refactoring (#3092) (#3103)

* minor refactoring in gunicorn module

* added changelog fragment

* reworked the gunicorn bin path part of the code, per PR

* Update changelogs/fragments/3092-gunicorn-refactor.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 549dfaae64)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-07-28 08:55:33 +02:00 committed by GitHub
parent c31424a924
commit 6e172f37af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- gunicorn - search for ``gunicorn`` binary in more paths (https://github.com/ansible-collections/community.general/pull/3092).

View file

@ -101,14 +101,12 @@ gunicorn:
import os import os
import time import time
# import ansible utils
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
def search_existing_config(config, option): def search_existing_config(config, option):
''' search in config file for specified option ''' ''' search in config file for specified option '''
if config and os.path.isfile(config): if config and os.path.isfile(config):
data_config = None
with open(config, 'r') as f: with open(config, 'r') as f:
for line in f: for line in f:
if option in line: if option in line:
@ -135,15 +133,12 @@ def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
app=dict(required=True, type='str', aliases=['name']), app=dict(required=True, type='str', aliases=['name']),
venv=dict(required=False, type='path', default=None, aliases=['virtualenv']), venv=dict(type='path', aliases=['virtualenv']),
config=dict(required=False, default=None, type='path', aliases=['conf']), config=dict(type='path', aliases=['conf']),
chdir=dict(required=False, type='path', default=None), chdir=dict(type='path'),
pid=dict(required=False, type='path', default=None), pid=dict(type='path'),
user=dict(required=False, type='str'), user=dict(type='str'),
worker=dict(required=False, worker=dict(type='str', choices=['sync', 'eventlet', 'gevent', 'tornado ', 'gthread', 'gaiohttp']),
type='str',
choices=['sync', 'eventlet', 'gevent', 'tornado ', 'gthread', 'gaiohttp']
),
) )
) )
@ -165,7 +160,7 @@ def main():
if venv: if venv:
gunicorn_command = "/".join((venv, 'bin', 'gunicorn')) gunicorn_command = "/".join((venv, 'bin', 'gunicorn'))
else: else:
gunicorn_command = 'gunicorn' gunicorn_command = module.get_bin_path('gunicorn')
# to daemonize the process # to daemonize the process
options = ["-D"] options = ["-D"]