Skip to content

Commit

Permalink
Merge pull request #59 from plesk/support-cl-mariadb
Browse files Browse the repository at this point in the history
Avoid starting mysqld service on plesk basic service startap
  • Loading branch information
SandakovMM authored Jul 29, 2024
2 parents 89d2a0a + 17822bc commit e59c050
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pleskdistup/actions/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,18 @@ def __init__(self) -> None:
self.name = "starting plesk services"
self.plesk_basic_services = [
"mariadb.service",
"mysqld.service",
"plesk-task-manager.service",
"plesk-web-socket.service",
"sw-cp-server.service",
"sw-engine.service",
]
self.plesk_basic_services = [service for service in self.plesk_basic_services if systemd.is_service_exists(service)]

# Once MariaDB has started, systemctl will not be able to control mysqld as a linked unit.
# Therefore, we should manage mysqld separately and only if MariaDB is not present
if "mariadb.service" not in self.plesk_basic_services and systemd.is_service_startable("mysqld.service"):
self.plesk_basic_services.append("mysqld.service")

def _enable_services(self) -> action.ActionResult:
# MariaDB could be started before, so we should stop it first
# TODO. Or we could check it is started and just remove it from list
Expand Down
6 changes: 6 additions & 0 deletions pleskdistup/common/src/dpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ def restore_installation() -> None:
def do_distupgrade() -> None:
util.logged_check_call(["apt-get", "dist-upgrade", "-y"] + APT_CHOOSE_OLD_FILES_OPTIONS,
env={"PATH": os.environ["PATH"], "DEBIAN_FRONTEND": "noninteractive"})


def get_installed_packages_list(regex: str) -> typing.List[str]:
res = subprocess.check_output(["/usr/bin/dpkg-query", "-W", "-f", "${binary:Package}\n", regex],
universal_newlines=True)
return res.splitlines()
2 changes: 1 addition & 1 deletion pleskdistup/common/src/mariadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, to_extract: str):

def __str__(self):
"""Return a string representation of a PHPVersion object."""
return f"PHP {self.major}.{self.minor}.{self.patch}"
return f"{self.major}.{self.minor}.{self.patch}"

def __lt__(self, other):
return self.major < other.major or (self.major == other.major and self.minor < other.minor) or (self.major == other.major and self.minor == other.minor and self.patch < other.patch)
Expand Down
10 changes: 10 additions & 0 deletions pleskdistup/common/src/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ def autoremove_outdated_packages() -> None:
return rpm.autoremove_outdated_packages()
else:
raise NotImplementedError(f"Unsupported distro {started_on}")


def get_installed_packages_list(regex: str) -> typing.List[str]:
started_on = dist.get_distro()
if started_on.deb_based:
return dpkg.get_installed_packages_list(regex)
elif started_on.rhel_based:
return rpm.get_installed_packages_list(regex)
else:
raise NotImplementedError(f"Unsupported distro {started_on}")
5 changes: 5 additions & 0 deletions pleskdistup/common/src/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ def install_packages(pkgs: typing.List[str], repository: typing.Optional[str] =
util.logged_check_call(command)


def get_installed_packages_list(regex: str) -> typing.List[str]:
res = subprocess.check_output(["/usr/bin/rpm", "-qa", "--queryformat", "%{NAME}\n", regex], universal_newlines=True)
return res.splitlines()


def remove_packages(pkgs: typing.List[str]) -> None:
if len(pkgs) == 0:
return
Expand Down

0 comments on commit e59c050

Please sign in to comment.