-
Notifications
You must be signed in to change notification settings - Fork 11
Convert Docker startup scripts to python #375
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
Changes from all commits
c037dcc
d62214b
4a3d431
61a564f
e8cc02f
b2f99ca
7a737fc
f6109aa
67ddbfd
ddb0ef5
5b04de6
827dfb9
1963d35
9650906
dc16079
1bb1de2
f5b5019
202465c
da765da
b3e92a2
21a34f1
8945ef8
27fd27e
bef5639
6fd7ee0
0aa0d8a
110f42b
f3ff5a3
75345cb
bcff419
3351859
3585e50
19984f2
c2b6215
97d443c
e949c77
0b46bfb
0b3aa2b
4a30c75
4cf94bb
71e74b7
009e092
c9924ec
32033a0
5fc3ecc
4747b8c
1d2910b
ba802c2
7e5fc18
e4c13ef
f7f7cb7
ac5a57d
a8280c2
553f8a6
62a8a16
85acff2
de12791
52f8fe6
ce25502
fcde27a
f3fe0e0
aa02bda
a555f43
1ff171f
faca04e
bcad37c
1f59f00
e4ff788
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 | ||
|
|
||
| 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 | ||
|
|
@@ -29,9 +30,10 @@ | |
| from collectoss.application.cli import test_connection, test_db_connection, with_database, DatabaseContext | ||
| import sqlalchemy as s | ||
|
|
||
| from collectoss.util.startup import check_init_schema, check_update_schema, collect_env_variables, print_platform_information, setup_facade_directory, warn_import_repos, merge_config | ||
| 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() | ||
|
|
||
|
|
@@ -60,8 +62,23 @@ def start(ctx, disable_collection, development, pidfile, port): | |
| signal.signal(signal.SIGTERM, manager.shutdown_signal_handler) | ||
| signal.signal(signal.SIGINT, manager.shutdown_signal_handler) | ||
|
|
||
|
|
||
| collect_env_variables(logger) | ||
|
|
||
|
|
||
| check_init_schema() | ||
| check_update_schema() | ||
|
|
||
| setup_facade_directory(logger) | ||
|
|
||
| merge_config(ctx.obj.engine, logger) | ||
|
|
||
| warn_import_repos(logger) | ||
|
|
||
| print_platform_information(logger) | ||
|
|
||
| try: | ||
| if os.environ.get('AUGUR_DOCKER_DEPLOY') != "1": | ||
| if SystemEnv.get('COLLECTOSS_DOCKER_DEPLOY') != "1": | ||
| raise_open_file_limit(100000) | ||
| except Exception as e: | ||
| logger.error( | ||
|
|
@@ -71,10 +88,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 +103,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 +147,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 +161,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('COLLECTOSS_DOCKER_DEPLOY') != "1": | ||
| orchestrator = subprocess.Popen("python keyman/Orchestrator.py".split()) | ||
|
|
||
| # Wait for orchestrator startup | ||
|
|
@@ -355,10 +372,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('COLLECTOSS_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('COLLECTOSS_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 +420,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 ConnectionError imported from redis.exceptions as RedisConnectionError (unused-import)