-
Notifications
You must be signed in to change notification settings - Fork 2
introduce a SystemEnv class to unify environment variable use and enable smooth transition
#311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6ecf484
4a33487
ad0b3ab
4941e5e
4f54506
13dda33
6bded2b
d9ac911
268c28c
65c8060
0653dd7
e8dcf87
e0f5a81
0c90b04
f2d487e
4db34b7
aeca9b9
fe0d072
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| from .LoginException import LoginException | ||
| from .Environment import Environment | ||
| from .LoginException import LoginException |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| import requests | ||
| from redis.exceptions import ConnectionError as RedisConnectionError | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
|
||
| from collectoss.application.environment import SystemEnv | ||
| from collectoss.tasks.start_tasks import collection_monitor, create_collection_status_records | ||
| from collectoss.tasks.git.facade_tasks import clone_repos | ||
| from collectoss.tasks.github.contributors import process_contributors | ||
|
|
@@ -31,7 +32,7 @@ | |
|
|
||
| from keyman.KeyClient import KeyClient, KeyPublisher | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
|
|
||
| reset_logs = os.getenv("AUGUR_RESET_LOGS", 'True').lower() in ('true', '1', 't', 'y', 'yes') | ||
| reset_logs = SystemEnv.get_bool("AUGUR_RESET_LOGS", True) | ||
|
|
||
| logger = SystemLogger("collectoss", reset_logfiles=reset_logs).get_logger() | ||
|
|
||
|
|
@@ -61,7 +62,7 @@ def start(ctx, disable_collection, development, pidfile, port): | |
| signal.signal(signal.SIGINT, manager.shutdown_signal_handler) | ||
|
|
||
| try: | ||
| if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1": | ||
| if SystemEnv.get('AUGUR_DOCKER_DEPLOY') != "1": | ||
| raise_open_file_limit(100000) | ||
| except Exception as e: | ||
| logger.error( | ||
|
|
@@ -71,10 +72,10 @@ def start(ctx, disable_collection, development, pidfile, port): | |
| raise e | ||
|
|
||
| if development: | ||
| os.environ["AUGUR_DEV"] = "1" | ||
| SystemEnv.set("AUGUR_DEV", "1") | ||
| logger.info("Starting in development mode") | ||
|
|
||
| os.environ["AUGUR_PIDFILE"] = pidfile | ||
| SystemEnv.set("AUGUR_PIDFILE", pidfile) | ||
|
|
||
| try: | ||
| gunicorn_location = os.getcwd() + "/collectoss/api/gunicorn_conf.py" | ||
|
|
@@ -86,10 +87,10 @@ def start(ctx, disable_collection, development, pidfile, port): | |
| if not port: | ||
| port = get_value("Server", "port") | ||
|
|
||
| os.environ["AUGUR_PORT"] = str(port) | ||
| SystemEnv.set("AUGUR_PORT", str(port)) | ||
|
|
||
| if disable_collection: | ||
| os.environ["AUGUR_DISABLE_COLLECTION"] = "1" | ||
| SystemEnv.set("AUGUR_DISABLE_COLLECTION", "1") | ||
|
|
||
| core_worker_count = get_value("Celery", 'core_worker_count') | ||
| secondary_worker_count = get_value("Celery", 'secondary_worker_count') | ||
|
|
@@ -130,7 +131,7 @@ def start(ctx, disable_collection, development, pidfile, port): | |
| processes = start_celery_worker_processes((core_worker_count, secondary_worker_count, facade_worker_count), disable_collection) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pylint] reported by reviewdog 🐶 |
||
| manager.processes = processes | ||
|
|
||
| celery_beat_schedule_db = os.getenv("CELERYBEAT_SCHEDULE_DB", "celerybeat-schedule.db") | ||
| celery_beat_schedule_db = SystemEnv.get("CELERYBEAT_SCHEDULE_DB", "celerybeat-schedule.db") | ||
| if os.path.exists(celery_beat_schedule_db): | ||
| logger.info("Deleting old task schedule") | ||
| os.remove(celery_beat_schedule_db) | ||
|
|
@@ -144,7 +145,7 @@ def start(ctx, disable_collection, development, pidfile, port): | |
| manager.keypub = keypub | ||
|
|
||
| if not disable_collection: | ||
| if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1": | ||
| if SystemEnv.get('AUGUR_DOCKER_DEPLOY') != "1": | ||
| orchestrator = subprocess.Popen("python keyman/Orchestrator.py".split()) | ||
|
|
||
| # Wait for orchestrator startup | ||
|
|
@@ -355,10 +356,10 @@ def export_env(config): | |
| Exports your GitHub key and database credentials | ||
| """ | ||
|
|
||
| export_file = open(os.getenv('AUGUR_EXPORT_FILE', 'collectoss_export_env.sh'), 'w+') | ||
| export_file = open(SystemEnv.get('AUGUR_EXPORT_FILE') or 'collectoss_export_env.sh', 'w+') | ||
| export_file.write('#!/bin/bash') | ||
| export_file.write('\n') | ||
| env_file = open(os.getenv('AUGUR_ENV_FILE', 'docker_env.txt'), 'w+') | ||
| env_file = open(SystemEnv.get('AUGUR_ENV_FILE') or 'docker_env.txt', 'w+') | ||
|
|
||
| for env_var in config.get_env_config().items(): | ||
| if "LOG" not in env_var[0]: | ||
|
|
@@ -403,7 +404,7 @@ def get_backend_processes(): | |
| for process in psutil.process_iter(['cmdline', 'name', 'environ']): | ||
| if process.info['cmdline'] is not None and process.info['environ'] is not None: | ||
| try: | ||
| if os.getenv('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in ''.join(process.info['cmdline'][:]).lower(): | ||
| if SystemEnv.get('VIRTUAL_ENV') in process.info['environ']['VIRTUAL_ENV'] and 'python' in ''.join(process.info['cmdline'][:]).lower(): | ||
| if process.pid != os.getpid(): | ||
| process_list.append(process) | ||
| except (KeyError, FileNotFoundError): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pylint] reported by reviewdog 🐶
W0611: Unused import os (unused-import)