Skip to content

Commit 8e42347

Browse files
committed
refact: fix last refactoring
1 parent 3dc61e0 commit 8e42347

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

demos/lib/phases.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ def run_prerequisites(ctx: DemoContext) -> bool:
6767
phase_start = time.time()
6868

6969
try:
70+
# For Docker backend, always set up the container first (regardless of --preflight)
71+
# This is required because Docker backend needs to create/start the container
72+
# before any other operations can run.
73+
if ctx.backend == "docker" and not ctx.preflight:
74+
from lib.commands import CommandError as CmdError
75+
76+
backend = ctx.get_backend()
77+
print_step("Setting up Docker container...")
78+
step_start = time.time()
79+
if not backend.setup():
80+
print_error("Failed to set up Docker container")
81+
raise CmdError("Docker container setup failed")
82+
record_timing("docker_setup", time.time() - step_start, category="setup")
83+
print_success(f"Docker container '{ctx.docker_container}' ready")
84+
pause(ctx.pause_between_steps)
85+
7086
# Preflight checks (only with --preflight)
7187
if ctx.preflight:
7288
step_start = time.time()

packages/hop3-installer/src/hop3_installer/server_installer/postgres.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ def _start_postgres_service(distro: str) -> bool:
3131
# Initialize PostgreSQL on Fedora (required before first start)
3232
if distro == "fedora":
3333
if not Path("/var/lib/pgsql/data/pg_hba.conf").exists():
34-
run_cmd(["postgresql-setup", "--initdb"], check=False)
34+
result = run_cmd(["postgresql-setup", "--initdb"], check=False)
35+
if result.returncode != 0:
36+
print_warning("PostgreSQL initialization failed")
37+
if result.stderr:
38+
print_detail(result.stderr[:200])
39+
40+
result = run_cmd(["systemctl", "enable", "postgresql"], check=False)
41+
if result.returncode != 0:
42+
print_warning("Failed to enable PostgreSQL service")
3543

36-
run_cmd(["systemctl", "enable", "postgresql"], check=False)
3744
result = run_cmd(["systemctl", "start", "postgresql"], check=False)
3845

3946
if result.returncode != 0:
@@ -139,7 +146,10 @@ def setup_postgres(config: ServerInstallerConfig, distro: str) -> str | None:
139146
print_success("PostgreSQL service started")
140147

141148
# Create role and database
142-
_create_postgres_role_and_db()
149+
if not _create_postgres_role_and_db():
150+
print_warning(
151+
"PostgreSQL role/database creation had issues - continuing anyway"
152+
)
143153

144154
# Set superuser password
145155
pg_password = _set_postgres_password()

packages/hop3-installer/src/hop3_installer/server_installer/user.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import subprocess # noqa: TC003
1111
from pathlib import Path
1212

13-
from hop3_installer.common import print_info, print_success, run_cmd
13+
from hop3_installer.common import print_info, print_success, print_warning, run_cmd
1414

1515
from .config import HOME_DIR, HOP3_GROUP, HOP3_USER
1616

@@ -74,7 +74,12 @@ def create_user_and_group() -> None:
7474
os.chown(HOME_DIR, hop3_uid, hop3_gid)
7575
Path(HOME_DIR).chmod(0o755)
7676

77-
# Add www-data to hop3 group
77+
# Add www-data to hop3 group (needed for nginx to access app sockets)
7878
if user_exists("www-data"):
79-
run_cmd(["usermod", "-a", "-G", HOP3_GROUP, "www-data"], check=False)
80-
print_info("Added www-data to hop3 group")
79+
result = run_cmd(["usermod", "-a", "-G", HOP3_GROUP, "www-data"], check=False)
80+
if result.returncode == 0:
81+
print_info("Added www-data to hop3 group")
82+
else:
83+
print_warning(
84+
"Failed to add www-data to hop3 group - nginx may have permission issues"
85+
)

0 commit comments

Comments
 (0)