Skip to content

Commit

Permalink
Merge pull request #114 from kobotoolbox/handle-secondary-backend
Browse files Browse the repository at this point in the history
Add secondary backend support
  • Loading branch information
rroux authored Sep 10, 2020
2 parents 7858f99 + 2e60cf2 commit 84f53dd
Show file tree
Hide file tree
Showing 12 changed files with 709 additions and 325 deletions.
52 changes: 26 additions & 26 deletions helpers/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def start_maintenance(cls):
"-f", "docker-compose.maintenance.yml",
"-f", "docker-compose.maintenance.override.yml",
"-p", config_object.get_prefix("maintenance"),
"up", "-d", "maintenance"]
"up", "-d"]

CLI.run_command(frontend_command, config.get("kobodocker_path"))
CLI.colored_print("Maintenance mode has been started",
Expand Down Expand Up @@ -313,9 +313,7 @@ def start(cls, frontend_only=False):
sys.exit(1)

# Start the back-end containers
if not frontend_only:
if not config_object.multi_servers or \
config_object.primary_backend or config_object.secondary_backend:
if not frontend_only and config_object.backend:
backend_role = config.get("backend_server_role", "primary")

backend_command = ["docker-compose",
Expand All @@ -329,12 +327,13 @@ def start(cls, frontend_only=False):
"up", "-d"]
CLI.run_command(backend_command, config.get("kobodocker_path"))

# If this was previously a shared-database setup, migrate to separate
# databases for KPI and KoBoCAT
migrate_single_to_two_databases()

# Start the front-end containers
if not config_object.multi_servers or config_object.frontend:
if config_object.frontend:

# If this was previously a shared-database setup, migrate to separate
# databases for KPI and KoBoCAT
migrate_single_to_two_databases()

frontend_command = ["docker-compose",
"-f", "docker-compose.frontend.yml",
"-f", "docker-compose.frontend.override.yml",
Expand Down Expand Up @@ -367,9 +366,12 @@ def start(cls, frontend_only=False):
"It can take a few minutes.", CLI.COLOR_SUCCESS)
cls.info()
else:
CLI.colored_print(("Backend server should be up & running! "
"Please look at docker logs for further "
"information"), CLI.COLOR_WARNING)
CLI.colored_print(
("{} backend server is starting up and should be "
"up & running soon!\nPlease look at docker logs for "
"further information: `python3 run.py -cb logs -f`".format(
config.get('backend_server_role'))),
CLI.COLOR_WARNING)

@classmethod
def stop(cls, output=True, frontend_only=False):
Expand Down Expand Up @@ -405,21 +407,19 @@ def stop(cls, output=True, frontend_only=False):
"down"]
CLI.run_command(proxy_command, config_object.get_letsencrypt_repo_path())

if not frontend_only:
if not config_object.multi_servers or config_object.primary_backend:

backend_role = config.get("backend_server_role", "primary")
if not frontend_only and config_object.backend:
backend_role = config.get("backend_server_role", "primary")

backend_command = [
"docker-compose",
"-f",
"docker-compose.backend.{}.yml".format(backend_role),
"-f",
"docker-compose.backend.{}.override.yml".format(backend_role),
"-p", config_object.get_prefix("backend"),
"down"
]
CLI.run_command(backend_command, config.get("kobodocker_path"))
backend_command = [
"docker-compose",
"-f",
"docker-compose.backend.{}.yml".format(backend_role),
"-f",
"docker-compose.backend.{}.override.yml".format(backend_role),
"-p", config_object.get_prefix("backend"),
"down"
]
CLI.run_command(backend_command, config.get("kobodocker_path"))

if output:
CLI.colored_print("KoBoToolbox has been stopped", CLI.COLOR_SUCCESS)
Expand Down
Loading

0 comments on commit 84f53dd

Please sign in to comment.