Skip to content
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

Merge rest of Andrew & Isaac Changes #2146

Merged
merged 164 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
8366b2e
Add user group functionality to repo load controller
ABrain7710 Nov 1, 2022
869a933
Merge augur-new-dev
ABrain7710 Nov 23, 2022
75e275e
Add user group table
ABrain7710 Dec 19, 2022
a7cd7fb
Changes for user groups
ABrain7710 Dec 19, 2022
5273944
Start working on converting old dbs to new version
ABrain7710 Dec 19, 2022
4005390
Add script to upgrade database
ABrain7710 Dec 20, 2022
7b45569
Fix up downgrade and upgrade script
ABrain7710 Dec 20, 2022
bc8e38e
Remove prints from script
ABrain7710 Dec 20, 2022
9c6ad2c
Fixes to repo insertion methods
ABrain7710 Dec 20, 2022
e63c27e
First run of adding repos to groups
ABrain7710 Dec 20, 2022
84f7668
Match the group id data types
ABrain7710 Dec 20, 2022
43f3eb0
Major improvements to user group functionality
ABrain7710 Dec 21, 2022
9cfafbf
Pass more repo load controller tests
ABrain7710 Dec 21, 2022
035ea8d
Move around tests for readability
ABrain7710 Dec 22, 2022
ef508ed
Add more tests
ABrain7710 Dec 22, 2022
b42648f
Add more tests
ABrain7710 Dec 22, 2022
3920591
Add more tests
ABrain7710 Dec 22, 2022
f75e217
Add more tests
ABrain7710 Dec 22, 2022
3d24577
Add more tests
ABrain7710 Dec 22, 2022
8e01729
Add more tests
ABrain7710 Dec 22, 2022
30ea9ce
Add more tests to repo load controller
ABrain7710 Jan 2, 2023
6ee51c1
Add more tests to repo load controller
ABrain7710 Jan 2, 2023
17de8eb
Fix deleting user errors
ABrain7710 Jan 3, 2023
965f415
Small fixes to user endpoints
ABrain7710 Jan 3, 2023
2154493
scaling fix for repo_move
IsaacMilarky Jan 3, 2023
427b0da
syntax
IsaacMilarky Jan 3, 2023
3db3aad
Add more tests for coverage
ABrain7710 Jan 3, 2023
167ca50
Add more endpoints to get the group and repo data for the frontend
ABrain7710 Jan 4, 2023
f65a88b
Add documentation and update User endpoints:
Ulincsys Jan 4, 2023
87da819
Change to rabbitmq broker
IsaacMilarky Jan 4, 2023
ff116a6
syntax
IsaacMilarky Jan 4, 2023
5412ae4
Add docs and a few fixes
ABrain7710 Jan 4, 2023
c5db0cf
don't ignore result
IsaacMilarky Jan 4, 2023
af250fa
More logging in detect_github_repo_move
IsaacMilarky Jan 4, 2023
7efce30
debug
IsaacMilarky Jan 4, 2023
a92df41
More oauth work
Ulincsys Jan 5, 2023
5ceb265
Merge branch 'augur-new-user-groups' of github.com:chaoss/augur into …
Ulincsys Jan 5, 2023
d55e8b2
print
IsaacMilarky Jan 5, 2023
4cbc210
Add auth to endpoints
ABrain7710 Jan 5, 2023
4d72ffc
re-add facade contributors to task queue
IsaacMilarky Jan 5, 2023
cf8b246
better handling and logging files model
IsaacMilarky Jan 5, 2023
22d10bd
Remove unneeded file
ABrain7710 Jan 5, 2023
9c15799
take advantage of rabbitmq allowing us to use celery result
IsaacMilarky Jan 5, 2023
b0829d0
syntax
IsaacMilarky Jan 5, 2023
b129087
Initial integration and testing
Ulincsys Jan 5, 2023
95702ed
Convert augur view login logic to the user orm model
ABrain7710 Jan 6, 2023
626c15f
Outline user methods on the user orm class
ABrain7710 Jan 6, 2023
dd9eed0
Update routes to use orm functions
ABrain7710 Jan 6, 2023
4e80daf
Fix some login bugs
ABrain7710 Jan 6, 2023
607d568
Add function to paginate all repos, user repos and group repos
ABrain7710 Jan 6, 2023
228bb7a
A functions to paginate user, group and all repos
ABrain7710 Jan 6, 2023
653b408
Fix syntax error
ABrain7710 Jan 6, 2023
9014529
Fixes
ABrain7710 Jan 6, 2023
bbe4593
Fix various bugs
ABrain7710 Jan 6, 2023
5c4ceb9
Remove prints
ABrain7710 Jan 7, 2023
e4b2a04
Make json endpoints only work when logged in
ABrain7710 Jan 7, 2023
23928c1
Return error if user is not logged in when using the api
ABrain7710 Jan 7, 2023
be82983
Add more function to orm
ABrain7710 Jan 7, 2023
a8541a9
Integration work
Ulincsys Jan 8, 2023
1e9cffc
Further integration testing and stability improvements
Ulincsys Jan 9, 2023
97d424f
Imporove error logging and fix error when loading a user or group repos
ABrain7710 Jan 9, 2023
7385ab3
Fix small errors in user login and improve logging
ABrain7710 Jan 9, 2023
a2464ac
Fix user deletion and improve logging when there are no valid github …
ABrain7710 Jan 9, 2023
79e63c2
Fix get repo by id in repo model
ABrain7710 Jan 9, 2023
55c6489
Stability improvements
Ulincsys Jan 9, 2023
d114c64
get rid of redundant definition
IsaacMilarky Jan 9, 2023
3b25c17
docs update
IsaacMilarky Jan 10, 2023
1d4eeca
further improvements
Ulincsys Jan 10, 2023
4dbad5a
Track templates directory
Ulincsys Jan 10, 2023
fdfa7b9
Make default group allowed, and return user group exists if it does
ABrain7710 Jan 10, 2023
8efebe2
Change celery task scheduling to not scale proportionally to the amou…
IsaacMilarky Jan 10, 2023
e79980a
Fix errors in the api
ABrain7710 Jan 10, 2023
03fd23a
User function improvements
ABrain7710 Jan 10, 2023
eceab1b
Remove print
ABrain7710 Jan 11, 2023
a33e7ff
analysis sequence pooling for facade scaling
IsaacMilarky Jan 11, 2023
81dfe66
need to fix issues with accessing redis
IsaacMilarky Jan 11, 2023
452bb35
don't create so many sessions
IsaacMilarky Jan 11, 2023
0425666
Add database changes and fixes to the api
ABrain7710 Jan 12, 2023
d3a045b
Added refresh endpoint
Ulincsys Jan 12, 2023
feea0fb
Update
IsaacMilarky Jan 12, 2023
c4e7c70
Add code for refresh tokens
ABrain7710 Jan 12, 2023
e4b30a9
Update auth requirements
Ulincsys Jan 12, 2023
7404086
Implement group favorite functionality
ABrain7710 Jan 12, 2023
05b209b
doc update
sgoggins Jan 12, 2023
cd19e71
Make session tokens expire
ABrain7710 Jan 12, 2023
c4a4833
fix facade date query error
IsaacMilarky Jan 12, 2023
df81664
Merge branch 'isaac-dev-mq' of github.com:chaoss/augur into isaac-dev-mq
IsaacMilarky Jan 12, 2023
61e247d
Fix error in unathorized handler
ABrain7710 Jan 12, 2023
33afbb9
remove excessive facade logging
IsaacMilarky Jan 12, 2023
9642a71
remove excessive facade logging
IsaacMilarky Jan 12, 2023
9fd7c9f
Merge branch 'dev' into view-integration-test
sgoggins Jan 12, 2023
30c759e
updating MQ and REDIS Docs
sgoggins Jan 12, 2023
69a73e2
Fix refresh endpoint response
Ulincsys Jan 12, 2023
b21071a
Merge branch 'view-integration' of github.com:chaoss/augur into view-…
Ulincsys Jan 12, 2023
71f336c
Fix conflicts
ABrain7710 Jan 12, 2023
52f1306
Add reverted changes
Ulincsys Jan 12, 2023
8ad30f0
Merge branch 'view-integration' into view-integration-test
ABrain7710 Jan 12, 2023
f8b6250
Updates to docs.
sgoggins Jan 12, 2023
f67139e
Fix schema revisions
ABrain7710 Jan 12, 2023
baf53e6
documentation updatese
sgoggins Jan 12, 2023
0130ff9
test
sgoggins Jan 12, 2023
f1018c2
Add pointer class to star, implement API toggle call
Ulincsys Jan 12, 2023
53c29ac
Fix error where frontend user recieved json
ABrain7710 Jan 12, 2023
7491190
Merge branch 'view-integration' into view-integration-test
ABrain7710 Jan 12, 2023
33c5e16
Merge branch 'docs-hold' into isaac-dev-mq
sgoggins Jan 12, 2023
bbeea0c
documentation updates
sgoggins Jan 12, 2023
885eb87
doc hell
sgoggins Jan 12, 2023
e9f1d53
trying
sgoggins Jan 12, 2023
ebd8397
Add fixes for oauth
ABrain7710 Jan 13, 2023
9ac37aa
analyze_commits_in_parallel now shows progress in quarters in the log…
IsaacMilarky Jan 13, 2023
2999caa
sql format
IsaacMilarky Jan 13, 2023
65b5f76
Typo
IsaacMilarky Jan 13, 2023
9d1a06f
skeleton for deps worker
IsaacMilarky Jan 13, 2023
c1dc021
Merge branch 'dev' into isaac-dev-mq
sgoggins Jan 15, 2023
f71420f
Better error handling
IsaacMilarky Jan 17, 2023
ad5d341
merge
IsaacMilarky Jan 17, 2023
84e6c5d
add dependency util files from main-old
IsaacMilarky Jan 17, 2023
103e0bb
Dependency worker
IsaacMilarky Jan 17, 2023
f4eba02
add dependency model to repo_collect
IsaacMilarky Jan 17, 2023
464b980
Syntax
IsaacMilarky Jan 17, 2023
fcf5e06
Facade tasks not getting ran for some reason
IsaacMilarky Jan 17, 2023
3bf5963
add file
IsaacMilarky Jan 17, 2023
09a9dd8
Remove bind from gunicorn command because it is specified in the guni…
ABrain7710 Jan 17, 2023
677d6d5
Remove config from database session object
ABrain7710 Jan 17, 2023
9b8e1e5
Remvove unneeded depencies form db connection code
ABrain7710 Jan 18, 2023
68451da
Make it possible to user the DatabaseSession in the orm models
ABrain7710 Jan 18, 2023
c713cdd
Clean up tests, refactor some poor design choices
ABrain7710 Jan 18, 2023
4374782
python import
IsaacMilarky Jan 18, 2023
fe3c084
Merge branch 'dependency-worker-translate-isaac' into dev-isaac
IsaacMilarky Jan 18, 2023
cab7dfe
make sure rabbitmq messages are cleared
IsaacMilarky Jan 18, 2023
bde277c
schedule less at once
IsaacMilarky Jan 18, 2023
a55d452
Grab correct vhost from config
IsaacMilarky Jan 18, 2023
7292e5a
optimistic
IsaacMilarky Jan 19, 2023
0e31c8a
Remove config from server object since it is unneeded
ABrain7710 Jan 19, 2023
9a77461
Fix 2 database connections staying open after starting augur
ABrain7710 Jan 19, 2023
14aa79b
Fix small errors
ABrain7710 Jan 19, 2023
0e7de07
Clean up GithubTaskSession objects when only a DatabaseSession is needed
ABrain7710 Jan 20, 2023
b1485af
Pass celery's globabl db engine to all sessions within tasks
ABrain7710 Jan 20, 2023
d30338a
Change repo_collect to split up task load for smaller message
IsaacMilarky Jan 20, 2023
a6a6916
version
IsaacMilarky Jan 20, 2023
a1e7d74
debug
IsaacMilarky Jan 20, 2023
a45ee5a
Low load patch
IsaacMilarky Jan 20, 2023
c2b15dc
Shrink facade messages
IsaacMilarky Jan 20, 2023
37cf1ec
syntax
IsaacMilarky Jan 20, 2023
28eb89b
syntax
IsaacMilarky Jan 20, 2023
2b72ea4
increase message load
IsaacMilarky Jan 20, 2023
8087cab
Merge branch 'dev' into dev-isaac
sgoggins Jan 21, 2023
81db9c3
Re-add the rabbitmq instructions and updated docker instructions
IsaacMilarky Jan 21, 2023
b681c01
Make facade not block collection
IsaacMilarky Jan 23, 2023
aeb9a7e
typo
IsaacMilarky Jan 23, 2023
930ecaf
prevent division by zero
IsaacMilarky Jan 23, 2023
a4a323f
Merge dev into branch
ABrain7710 Jan 23, 2023
257cacb
Fix errors caused by merge
ABrain7710 Jan 23, 2023
3049304
Fix various errors
ABrain7710 Jan 23, 2023
7701d22
releases err handle
IsaacMilarky Jan 24, 2023
d4f98fb
50 not 5
IsaacMilarky Jan 24, 2023
dabc283
merge
IsaacMilarky Jan 24, 2023
9774c0b
weird github response handle
IsaacMilarky Jan 24, 2023
b31b943
cleanup logs
IsaacMilarky Jan 25, 2023
f8665ca
resolve conflicts
IsaacMilarky Jan 25, 2023
e96adf3
more conflicts
IsaacMilarky Jan 25, 2023
394c5a4
more merges
IsaacMilarky Jan 25, 2023
2904781
more merge conflicts
IsaacMilarky Jan 25, 2023
051afc9
Make operational error more explicit
ABrain7710 Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions augur/api/gunicorn_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import shutil

from augur.application.db.session import DatabaseSession
from augur.application.config import AugurConfig

logger = logging.getLogger(__name__)
with DatabaseSession(logger) as session:

augur_config = AugurConfig(logger, session)


# ROOT_AUGUR_DIRECTORY = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

Expand All @@ -21,21 +25,21 @@
reload = True

# set the log location for gunicorn
logs_directory = session.config.get_value('Logging', 'logs_directory')
logs_directory = augur_config.get_value('Logging', 'logs_directory')
accesslog = f"{logs_directory}/gunicorn.log"
errorlog = f"{logs_directory}/gunicorn.log"

ssl_bool = session.config.get_value('Server', 'ssl')
ssl_bool = augur_config.get_value('Server', 'ssl')

if ssl_bool is True:

workers = int(session.config.get_value('Server', 'workers'))
bind = '%s:%s' % (session.config.get_value("Server", "host"), session.config.get_value("Server", "port"))
timeout = int(session.config.get_value('Server', 'timeout'))
certfile = str(session.config.get_value('Server', 'ssl_cert_file'))
keyfile = str(session.config.get_value('Server', 'ssl_key_file'))
workers = int(augur_config.get_value('Server', 'workers'))
bind = '%s:%s' % (augur_config.get_value("Server", "host"), augur_config.get_value("Server", "port"))
timeout = int(augur_config.get_value('Server', 'timeout'))
certfile = str(augur_config.get_value('Server', 'ssl_cert_file'))
keyfile = str(augur_config.get_value('Server', 'ssl_key_file'))

else:
workers = int(session.config.get_value('Server', 'workers'))
bind = '%s:%s' % (session.config.get_value("Server", "host"), session.config.get_value("Server", "port"))
timeout = int(session.config.get_value('Server', 'timeout'))
workers = int(augur_config.get_value('Server', 'workers'))
bind = '%s:%s' % (augur_config.get_value("Server", "host"), augur_config.get_value("Server", "port"))
timeout = int(augur_config.get_value('Server', 'timeout'))
3 changes: 2 additions & 1 deletion augur/api/routes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Disable the requirement for SSL by setting env["AUGUR_DEV"] = True
from augur.application.config import get_development_flag
from augur.application.db.models import Config
from augur.application.config import AugurConfig
from augur.application.db.session import DatabaseSession

logger = logging.getLogger(__name__)
Expand All @@ -35,7 +36,7 @@ def get_config():

with DatabaseSession(logger) as session:

config_dict = session.config.load_config()
config_dict = AugurConfig(logger, session).config.load_config()

return jsonify(config_dict), 200

Expand Down
12 changes: 4 additions & 8 deletions augur/api/routes/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def validate_user():

return jsonify({"status": "Validated"})


@server.app.route(f"/{AUGUR_API_VERSION}/user/logout", methods=['POST'])
@login_required
def logout_user_func():
Expand Down Expand Up @@ -447,13 +448,7 @@ def get_user_groups():
@server.app.route(f"/{AUGUR_API_VERSION}/user/groups/repos/", methods=['GET', 'POST'])
@login_required
def get_user_groups_and_repos():
"""Get a list of user groups and their repos

Returns
-------
list
A list with this strucutre : [{"<group_name>": <list_of_repos}, ...]
"""
"""Get a list of user groups and their repos"""

if not development and not request.is_secure:
return generate_upgrade_request()
Expand All @@ -463,7 +458,7 @@ def get_user_groups_and_repos():
return {"status": "Missing argument columns"}

# split list by , and remove whitespaces from edges

valid_columns = []
columns = columns.split(",")
for column in columns:
Expand Down Expand Up @@ -542,3 +537,4 @@ def get_favorite_groups():
group_names = [group.name for group in groups]

return jsonify({"status": "success", "group_names": group_names})

3 changes: 2 additions & 1 deletion augur/api/routes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from augur.application.db.session import DatabaseSession
from augur.application.logs import AugurLogger
from augur.application.config import AugurConfig

logger = AugurLogger("augur").get_logger()

Expand Down Expand Up @@ -220,7 +221,7 @@ def api_port():

with DatabaseSession(logger) as session:

response = {'port': session.config.get_value('Server', 'port')}
response = {'port': AugurConfig(logger, session).get_value('Server', 'port')}
return Response(response=json.dumps(response),
status=200,
mimetype="application/json")
14 changes: 8 additions & 6 deletions augur/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from augur.application.db.session import DatabaseSession
from augur.application.logs import AugurLogger
from augur.application.config import AugurConfig
from metadata import __version__ as augur_code_version

from augur.api.routes import AUGUR_API_VERSION
Expand All @@ -48,9 +49,7 @@ def __init__(self):
"""Initialize the Server class."""

self.logger = AugurLogger("server").get_logger()
self.session = DatabaseSession(self.logger)
self.config = self.session.config
self.engine = self.session.engine


self.cache_manager = self.create_cache_manager()
self.server_cache = self.get_server_cache()
Expand Down Expand Up @@ -436,9 +435,12 @@ def get_server_cache(self) -> Cache:
server cache
"""

expire = int(self.config.get_value('Server', 'cache_expire'))
server_cache = self.cache_manager.get_cache('server', expire=expire)
server_cache.clear()
with DatabaseSession(self.logger) as session:
config = AugurConfig(self.logger, session)

expire = int(config.get_value('Server', 'cache_expire'))
server_cache = self.cache_manager.get_cache('server', expire=expire)
server_cache.clear()

return server_cache

Expand Down
7 changes: 4 additions & 3 deletions augur/api/view/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask import Flask, render_template, render_template_string, request, abort, jsonify, redirect, url_for, session, flash
from flask_login import current_user, login_required
from augur.util.repo_load_controller import parse_org_url, parse_repo_url
from augur.application.db.models import Repo
# from augur.util.repo_load_controller import parse_org_url, parse_repo_url
from .utils import *

def create_routes(server):
Expand All @@ -22,10 +23,10 @@ def av_add_user_repo():

if not url or not group:
flash("Repo or org URL must not be empty")
elif parse_org_url(url):
elif Repo.parse_github_org_url(url):
current_user.add_org(group, url)
flash("Successfully added org")
elif parse_repo_url(url):
elif Repo.parse_github_repo_url(url):
current_user.add_repo(group, url)
flash("Successfully added repo")
else:
Expand Down
55 changes: 31 additions & 24 deletions augur/api/view/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

logger = logging.getLogger(__name__)

with DatabaseSession(logger) as db_session:
config = AugurConfig(logger, db_session)

# ROUTES -----------------------------------------------------------------------

Expand Down Expand Up @@ -71,8 +69,12 @@ def repo_table_view():
rev = True

direction = "DESC" if rev else "ASC"

pagination_offset = config.get_value("frontend", "pagination_offset")

with DatabaseSession(logger) as db_session:
config = AugurConfig(logger, db_session)

pagination_offset = config.get_value("frontend", "pagination_offset")


if current_user.is_authenticated:
data = current_user.get_repos(page = page, sort = sorting, direction = direction)[0]
Expand Down Expand Up @@ -153,26 +155,28 @@ def user_login():
if username is None:
raise LoginException("A login issue occurred")

user = User.get_user(username)
if not user and register is None:
raise LoginException("Invalid login credentials")

# register a user
if register is not None:
if user:
raise LoginException("User already exists")
with DatabaseSession(logger) as db_session:
user = User.get_user(db_session, username)

if not user and register is None:
raise LoginException("Invalid login credentials")

email = request.form.get('email')
first_name = request.form.get('first_name')
last_name = request.form.get('last_name')
admin = request.form.get('admin') or False

result = User.create_user(username, password, email, first_name, last_name, admin)
if not result[0]:
raise LoginException("An error occurred registering your account")
else:
user = User.get_user(username)
flash(result[1]["status"])
# register a user
if register is not None:
if user:
raise LoginException("User already exists")

email = request.form.get('email')
first_name = request.form.get('first_name')
last_name = request.form.get('last_name')
admin = request.form.get('admin') or False

result = User.create_user(db_session, username, password, email, first_name, last_name, admin)
if not result[0]:
raise LoginException("An error occurred registering your account")
else:
user = User.get_user(username)
flash(result[1]["status"])

# Log the user in if the password is valid
if user.validate(password) and login_user(user, remember = remember):
Expand Down Expand Up @@ -285,7 +289,10 @@ def user_group_view():
rev = True
params["direction"] = "DESC"

pagination_offset = config.get_value("frontend", "pagination_offset")
with DatabaseSession(logger) as db_session:
config = AugurConfig(logger, db_session)

pagination_offset = config.get_value("frontend", "pagination_offset")

data = current_user.get_group_repos(group, **params)[0]
page_count = (current_user.get_group_repo_count(group)[0]) or 0
Expand Down
3 changes: 2 additions & 1 deletion augur/application/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def new_func(ctx, *args, **kwargs):
#try to ping google's dns server
socket.create_connection(("8.8.8.8",53))
return ctx.invoke(function_internet_connection, *args, **kwargs)
except OSError:
except OSError as e:
print(e)
print(f"\n\n{usage} command setup failed\nYou are not connect to the internet. Please connect to the internet to run Augur\n")
sys.exit()

Expand Down
71 changes: 40 additions & 31 deletions augur/application/cli/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from augur.application.db.models import Repo
from augur.application.db.session import DatabaseSession
from augur.application.logs import AugurLogger
from augur.application.config import AugurConfig
from augur.application.cli import test_connection, test_db_connection


Expand Down Expand Up @@ -55,45 +56,50 @@ def start(disable_collection, development, port):
os.environ["AUGUR_DEV"] = "1"
logger.info("Starting in development mode")


with DatabaseSession(logger) as session:

try:
gunicorn_location = os.getcwd() + "/augur/api/gunicorn_conf.py"
host = session.config.get_value("Server", "host")
except FileNotFoundError:
logger.error("\n\nPlease run augur commands in the root directory\n\n")

if not port:
port = session.config.get_value("Server", "port")
db_session = DatabaseSession(logger)
config = AugurConfig(logger, db_session)
host = config.get_value("Server", "host")

gunicorn_command = f"gunicorn -c {gunicorn_location} -b {host}:{port} --preload augur.api.server:app"
server = subprocess.Popen(gunicorn_command.split(" "))
if not port:
port = config.get_value("Server", "port")

db_session.invalidate()

gunicorn_command = f"gunicorn -c {gunicorn_location} -b {host}:{port} --preload augur.api.server:app"
server = subprocess.Popen(gunicorn_command.split(" "))

time.sleep(3)
logger.info('Gunicorn webserver started...')
logger.info(f'Augur is running at: http://127.0.0.1:{session.config.get_value("Server", "port")}')
time.sleep(3)
logger.info('Gunicorn webserver started...')
logger.info(f'Augur is running at: http://127.0.0.1:{port}')

worker_1_process = None
cpu_worker_process = None
celery_beat_process = None
if not disable_collection:
worker_1_process = None
cpu_worker_process = None
celery_beat_process = None
if not disable_collection:

if os.path.exists("celerybeat-schedule.db"):
logger.info("Deleting old task schedule")
os.remove("celerybeat-schedule.db")
if os.path.exists("celerybeat-schedule.db"):
logger.info("Deleting old task schedule")
os.remove("celerybeat-schedule.db")

worker_1 = f"celery -A augur.tasks.init.celery_app.celery_app worker -P eventlet -l info --concurrency=100 -n {uuid.uuid4().hex}@%h"
cpu_worker = f"celery -A augur.tasks.init.celery_app.celery_app worker -l info --concurrency=20 -n {uuid.uuid4().hex}@%h -Q cpu"
worker_1_process = subprocess.Popen(worker_1.split(" "))
worker_1 = f"celery -A augur.tasks.init.celery_app.celery_app worker -P eventlet -l info --concurrency=100 -n {uuid.uuid4().hex}@%h"
cpu_worker = f"celery -A augur.tasks.init.celery_app.celery_app worker -l info --concurrency=20 -n {uuid.uuid4().hex}@%h -Q cpu"
worker_1_process = subprocess.Popen(worker_1.split(" "))

cpu_worker_process = subprocess.Popen(cpu_worker.split(" "))
time.sleep(5)
cpu_worker_process = subprocess.Popen(cpu_worker.split(" "))
time.sleep(5)

start_task.si().apply_async()
start_task.si().apply_async()

celery_command = "celery -A augur.tasks.init.celery_app.celery_app beat -l debug"
celery_beat_process = subprocess.Popen(celery_command.split(" "))
celery_command = "celery -A augur.tasks.init.celery_app.celery_app beat -l debug"
celery_beat_process = subprocess.Popen(celery_command.split(" "))

else:
logger.info("Collection disabled")
else:
logger.info("Collection disabled")

try:
server.wait()
Expand All @@ -119,7 +125,8 @@ def start(disable_collection, development, port):
clear_redis_caches()
connection_string = ""
with DatabaseSession(logger) as session:
connection_string = session.config.get_section("RabbitMQ")['connection_string']
config = AugurConfig(logger, session)
connection_string = config.get_section("RabbitMQ")['connection_string']

clear_rabbitmq_messages(connection_string)

Expand All @@ -138,7 +145,8 @@ def stop():
clear_redis_caches()
connection_string = ""
with DatabaseSession(logger) as session:
connection_string = session.config.get_section("RabbitMQ")['connection_string']
config = AugurConfig(logger, session)
connection_string = config.get_section("RabbitMQ")['connection_string']

clear_rabbitmq_messages(connection_string)

Expand All @@ -154,7 +162,8 @@ def kill():

connection_string = ""
with DatabaseSession(logger) as session:
connection_string = session.config.get_section("RabbitMQ")['connection_string']
config = AugurConfig(logger, session)
connection_string = config.get_section("RabbitMQ")['connection_string']

clear_rabbitmq_messages(connection_string)

Expand Down
Loading