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

enable services to start on system start #252

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def _on_start(self, event: StartEvent) -> None:
self.unit.status = MaintenanceStatus("starting MongoDB")
snap_cache = snap.SnapCache()
mongodb_snap = snap_cache["charmed-mongodb"]
mongodb_snap.start(services=["mongod"])
mongodb_snap.start(services=["mongod"], enable=True)
self.unit.status = ActiveStatus()
except snap.SnapError as e:
logger.error("An exception occurred when starting mongod agent, error: %s.", str(e))
Expand Down Expand Up @@ -912,7 +912,7 @@ def _connect_pbm_agent(self) -> None:
# Added to avoid systemd error:
# 'snap.charmed-mongodb.pbm-agent.service: Start request repeated too quickly'
time.sleep(1)
pbm_snap.start(services=[Config.Backup.SERVICE_NAME])
pbm_snap.start(services=[Config.Backup.SERVICE_NAME], enable=True)
except snap.SnapError as e:
logger.error(f"Failed to restart {Config.Backup.SERVICE_NAME}: {str(e)}")
self._get_service_status(Config.Backup.SERVICE_NAME)
Expand Down Expand Up @@ -1035,7 +1035,7 @@ def restart_mongod_service(self, auth=None):
self._unit_ip(self.unit),
config=self.mongodb_config,
)
mongodb_snap.start(services=["mongod"])
mongodb_snap.start(services=["mongod"], enable=True)
except snap.SnapError as e:
logger.error("An exception occurred when starting mongod agent, error: %s.", str(e))
self.unit.status = BlockedStatus("couldn't start MongoDB")
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def start_backup_service(self) -> None:
"""
snap_cache = snap.SnapCache()
charmed_mongodb_snap = snap_cache["charmed-mongodb"]
charmed_mongodb_snap.start(services=["pbm-agent"])
charmed_mongodb_snap.start(services=["pbm-agent"], enable=True)

def restart_backup_service(self) -> None:
"""Restarts the pbm agent.
Expand Down
Loading