Add RabbitMQ support to Manage Applications and lifecycle flows.

Wire RabbitMQ into app management UI/actions, optional fresh-install flag handling, and upgrade-safe marker/service reconciliation so new installs and upgrades can expose it reliably.
This commit is contained in:
master3395
2026-03-31 20:41:00 +02:00
parent 2c1b6ad557
commit 95e38e70f3
6 changed files with 156 additions and 0 deletions

View File

@@ -6250,6 +6250,31 @@ vmail
command = 'systemctl enable redis'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
def installRabbitMQ(self):
rabbitMQMarker = '/home/cyberpanel/rabbitmq'
# Keep optional installer idempotent for reruns/retries.
if os.path.exists(rabbitMQMarker):
preFlightsChecks.stdOut("RabbitMQ marker already exists, skipping optional RabbitMQ installation.")
return
if self.distro == ubuntu or self.distro == debian12:
command = 'DEBIAN_FRONTEND=noninteractive apt install rabbitmq-server -y'
elif self.distro == centos:
command = 'yum install rabbitmq-server -y'
else:
command = 'dnf install rabbitmq-server -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'systemctl enable rabbitmq-server'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
command = 'systemctl start rabbitmq-server'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
writeToFile = open(rabbitMQMarker, 'w')
writeToFile.close()
def disablePackegeUpdates(self):
if self.distro == centos:
mainConfFile = '/etc/yum.conf'
@@ -6752,6 +6777,7 @@ def main():
parser.add_argument('--serial', help='Install LS Ent or OpenLiteSpeed')
parser.add_argument('--port', help='LSCPD Port')
parser.add_argument('--redis', help='vHosts on Redis - Requires LiteSpeed Enterprise')
parser.add_argument('--rabbitmq', help='Enable optional RabbitMQ installation.')
parser.add_argument('--remotemysql', help='Opt to choose local or remote MySQL')
parser.add_argument('--mysqlhost', help='MySQL host if remote is chosen.')
parser.add_argument('--mysqldb', help='MySQL DB if remote is chosen.')
@@ -7020,6 +7046,9 @@ def main():
if args.redis is not None:
checks.installRedis()
if args.rabbitmq is not None and str(args.rabbitmq).upper() == 'ON':
checks.installRabbitMQ()
if args.powerdns is not None:
checks.enableDisableDNS(args.powerdns.lower())
else:

View File

@@ -304,6 +304,72 @@ type=rpm-md
"Redis successfully removed.[200]\n", 1)
return 0
@staticmethod
def InstallRabbitMQ():
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
try:
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
command = 'yum install rabbitmq-server -y'
ServerStatusUtil.executioner(command, statusFile)
else:
command = 'DEBIAN_FRONTEND=noninteractive apt-get install rabbitmq-server -y'
ServerStatusUtil.executioner(command, statusFile)
command = 'systemctl enable rabbitmq-server'
ServerStatusUtil.executioner(command, statusFile)
command = 'systemctl start rabbitmq-server'
ServerStatusUtil.executioner(command, statusFile)
command = 'touch /home/cyberpanel/rabbitmq'
ServerStatusUtil.executioner(command, statusFile)
logging.CyberCPLogFileWriter.statusWriter(
ServerStatusUtil.lswsInstallStatusPath,
"RabbitMQ successfully installed.[200]\n", 1
)
return 0
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(
ServerStatusUtil.lswsInstallStatusPath,
"RabbitMQ installation failed: %s.[500]\n" % (str(msg)), 0
)
return 1
@staticmethod
def RemoveRabbitMQ():
statusFile = open(ServerStatusUtil.lswsInstallStatusPath, 'w')
try:
command = 'systemctl stop rabbitmq-server'
ServerStatusUtil.executioner(command, statusFile)
command = 'systemctl disable rabbitmq-server'
ServerStatusUtil.executioner(command, statusFile)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
command = 'yum erase rabbitmq-server -y'
ServerStatusUtil.executioner(command, statusFile)
else:
command = 'DEBIAN_FRONTEND=noninteractive apt-get remove rabbitmq-server -y'
ServerStatusUtil.executioner(command, statusFile)
command = 'rm -f /home/cyberpanel/rabbitmq'
ServerStatusUtil.executioner(command, statusFile)
logging.CyberCPLogFileWriter.statusWriter(
ServerStatusUtil.lswsInstallStatusPath,
"RabbitMQ successfully removed.[200]\n", 1
)
return 0
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(
ServerStatusUtil.lswsInstallStatusPath,
"RabbitMQ removal failed: %s.[500]\n" % (str(msg)), 0
)
return 1
def main():
parser = argparse.ArgumentParser(description='CyberPanel Application Manager')
@@ -320,6 +386,10 @@ def main():
ServiceManager.InstallRedis()
elif args["function"] == "RemoveRedis":
ServiceManager.RemoveRedis()
elif args["function"] == "InstallRabbitMQ":
ServiceManager.InstallRabbitMQ()
elif args["function"] == "RemoveRabbitMQ":
ServiceManager.RemoveRabbitMQ()

View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512" role="img" aria-labelledby="title desc">
<title id="title">RabbitMQ</title>
<desc id="desc">RabbitMQ application icon</desc>
<rect width="512" height="512" rx="96" fill="#ff6600"/>
<path d="M118 154h102v66H118zm0 92h102v66H118zm0 92h102v66H118zm136-184h102v66H254zm0 92h102v66H254zm0 92h102v66H254zm136-184h4c18 0 32 14 32 32v216c0 18-14 32-32 32h-4V154z" fill="#fff"/>
</svg>

After

Width:  |  Height:  |  Size: 464 B

View File

@@ -405,6 +405,8 @@
{% trans "A distributed, RESTful search and analytics engine capable of addressing a growing number of use cases." %}
{% elif service.name == 'Redis' %}
{% trans "An in-memory data structure store, used as a database, cache, and message broker." %}
{% elif service.name == 'RabbitMQ' %}
{% trans "A reliable message broker for asynchronous processing, queueing, and service-to-service communication." %}
{% else %}
{% trans "Powerful application for your server infrastructure." %}
{% endif %}

View File

@@ -276,6 +276,7 @@ def manageApplications(request):
esPath = '/home/cyberpanel/elasticsearch'
rPath = '/home/cyberpanel/redis'
rmqPath = '/home/cyberpanel/rabbitmq'
if os.path.exists(esPath):
installed = 'Installed'
@@ -287,12 +288,20 @@ def manageApplications(request):
else:
rInstalled = 'Not-Installed'
if os.path.exists(rmqPath):
rmqInstalled = 'Installed'
else:
rmqInstalled = 'Not-Installed'
elasticSearch = {'image': '/static/manageServices/images/elastic-search.png', 'name': 'Elasticsearch',
'installed': installed}
redis = {'image': '/static/manageServices/images/redis.png', 'name': 'Redis',
'installed': rInstalled}
rabbitmq = {'image': '/static/manageServices/images/rabbitmq.svg', 'name': 'RabbitMQ',
'installed': rmqInstalled}
services.append(elasticSearch)
services.append(redis)
services.append(rabbitmq)
proc = httpProc(request, 'manageServices/applications.html',
{'services': services}, 'admin')
@@ -323,6 +332,15 @@ def removeInstall(request):
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallRedis'
else:
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function RemoveRedis'
elif appName == 'RabbitMQ':
if status == 'Installing':
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function InstallRabbitMQ'
else:
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/manageServices/serviceManager.py --function RemoveRabbitMQ'
else:
data_ret = {'status': 0, 'error_message': 'Unknown application selected.'}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
ProcessUtilities.popenExecutioner(command)
data_ret = {'status': 1}

View File

@@ -4434,6 +4434,36 @@ class Migration(migrations.Migration):
except:
pass
@staticmethod
def rabbitMQMigrations():
marker_path = '/home/cyberpanel/rabbitmq'
rabbitmq_service_files = [
'/usr/lib/systemd/system/rabbitmq-server.service',
'/lib/systemd/system/rabbitmq-server.service'
]
rabbitmq_binary_paths = [
'/usr/sbin/rabbitmq-server',
'/usr/lib/rabbitmq/bin/rabbitmq-server'
]
try:
rabbitmq_installed = any(os.path.exists(path) for path in rabbitmq_service_files + rabbitmq_binary_paths)
if rabbitmq_installed:
if not os.path.exists(marker_path):
writeToFile = open(marker_path, 'w+')
writeToFile.close()
Upgrade.stdOut('RabbitMQ detected during upgrade. Marker file created.', 0)
Upgrade.executioner('systemctl enable rabbitmq-server', 'Enable RabbitMQ service', 0)
Upgrade.executioner('systemctl start rabbitmq-server', 'Start RabbitMQ service', 0)
else:
if os.path.exists(marker_path):
os.remove(marker_path)
Upgrade.stdOut('RabbitMQ marker removed because service is not installed.', 0)
except BaseException as msg:
Upgrade.stdOut('RabbitMQ migration failed: ' + str(msg), 0)
@staticmethod
def backupCriticalFiles():
"""Backup all critical configuration files before upgrade"""
@@ -6652,6 +6682,7 @@ slowlog = /var/log/php{version}-fpm-slow.log
Upgrade.setupWebmail()
Upgrade.setupSieve()
Upgrade.enableServices()
Upgrade.rabbitMQMigrations()
# Apply AlmaLinux 9 fixes before other installations
Upgrade.fix_almalinux9_mariadb()