From 7c2dad71a7929de47a69da9bd870e5a47e308914 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 15 Jul 2022 11:46:33 +0200 Subject: [PATCH 1/9] Move api, auth and stream service unit files to generator so st2.conf variables are used consistently for .socket and .service files. --- packages/st2/debian/st2api-generator | 31 +++++++++++++++++++-- packages/st2/debian/st2api.service | 19 ------------- packages/st2/debian/st2auth-generator | 37 +++++++++++++++++++++---- packages/st2/debian/st2auth.service | 19 ------------- packages/st2/debian/st2stream-generator | 37 +++++++++++++++++++++---- packages/st2/debian/st2stream.service | 19 ------------- packages/st2/rpm/st2.spec | 3 -- 7 files changed, 90 insertions(+), 75 deletions(-) delete mode 100644 packages/st2/debian/st2api.service delete mode 100644 packages/st2/debian/st2auth.service delete mode 100644 packages/st2/debian/st2stream.service diff --git a/packages/st2/debian/st2api-generator b/packages/st2/debian/st2api-generator index ae6d2e7ee..a118a8966 100755 --- a/packages/st2/debian/st2api-generator +++ b/packages/st2/debian/st2api-generator @@ -37,7 +37,7 @@ section = ST2SVC[3:] bind_address = config[section].get("host", DEFAULT_IP) bind_port = config[section].get("port", DEFAULT_PORT) -contents = f"""[Unit] +socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} Description=StackStorm {ST2SVC} Socket. PartOf={ST2SVC}.service @@ -51,6 +51,31 @@ WantedBy=sockets.target """ with open(f"{NORMAL_DIR}/{ST2SVC}.socket", "w") as f: - f.write(contents) + f.write(socket_contents) -LOG.info(f"{ST2SVC} generated.") +LOG.info(f"{ST2SVC} socket generated.") + +unit_contents = f"""[Unit] +# Generated by {sys.argv[0]} at {time.asctime(time.localtime())} +Description=StackStorm service {ST2SVC} +After=network.target {ST2SVC}.socket +Requires={ST2SVC}.socket + +[Service] +Type=simple +User=st2 +Group=st2 +ExecStart=/opt/stackstorm/st2/bin/gunicorn {ST2SVC}.wsgi:application -k eventlet -b {bind_address}:{bind_port} --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.api.gunicorn.conf --error-logfile /var/log/st2/{ST2SVC}.log +TimeoutSec=60 +PrivateTmp=true +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +""" + +with open(f"{NORMAL_DIR}/{ST2SVC}.service", "w") as f: + f.write(unit_contents) + +LOG.info(f"{ST2SVC} unit generated") diff --git a/packages/st2/debian/st2api.service b/packages/st2/debian/st2api.service deleted file mode 100644 index 1921126db..000000000 --- a/packages/st2/debian/st2api.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=StackStorm service st2api -After=network.target st2api.socket -Requires=st2api.socket - -[Service] -Type=simple -User=st2 -Group=st2 -Environment="DAEMON_ARGS=-k eventlet -b 127.0.0.1:9101 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.api.gunicorn.conf --error-logfile /var/log/st2/st2api.log" -EnvironmentFile=-/etc/default/st2api -ExecStart=/opt/stackstorm/st2/bin/gunicorn st2api.wsgi:application $DAEMON_ARGS -TimeoutSec=60 -PrivateTmp=true -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target diff --git a/packages/st2/debian/st2auth-generator b/packages/st2/debian/st2auth-generator index f1b017e99..6f30f4c34 100755 --- a/packages/st2/debian/st2auth-generator +++ b/packages/st2/debian/st2auth-generator @@ -4,9 +4,9 @@ import logging import time import sys -ST2SVC="st2auth" -DEFAULT_IP="127.0.0.1" -DEFAULT_PORT="9100" +ST2SVC = "st2auth" +DEFAULT_IP = "127.0.0.1" +DEFAULT_PORT = "9101" ST2CFG = "/etc/st2/st2.conf" # Systemd passes 3 paths to a generator, normal_dir, early_dir, late_dir. @@ -37,7 +37,7 @@ section = ST2SVC[3:] bind_address = config[section].get("host", DEFAULT_IP) bind_port = config[section].get("port", DEFAULT_PORT) -contents = f"""[Unit] +socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} Description=StackStorm {ST2SVC} Socket. PartOf={ST2SVC}.service @@ -51,6 +51,31 @@ WantedBy=sockets.target """ with open(f"{NORMAL_DIR}/{ST2SVC}.socket", "w") as f: - f.write(contents) + f.write(socket_contents) -LOG.info(f"{ST2SVC} generated.") +LOG.info(f"{ST2SVC} socket generated.") + +unit_contents = f"""[Unit] +# Generated by {sys.argv[0]} at {time.asctime(time.localtime())} +Description=StackStorm service {ST2SVC} +After=network.target {ST2SVC}.socket +Requires={ST2SVC}.socket + +[Service] +Type=simple +User=st2 +Group=st2 +ExecStart=/opt/stackstorm/st2/bin/gunicorn {ST2SVC}.wsgi:application -k eventlet -b {bind_address}:{bind_port} --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.api.gunicorn.conf --error-logfile /var/log/st2/{ST2SVC}.log +TimeoutSec=60 +PrivateTmp=true +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +""" + +with open(f"{NORMAL_DIR}/{ST2SVC}.service", "w") as f: + f.write(unit_contents) + +LOG.info(f"{ST2SVC} unit generated") diff --git a/packages/st2/debian/st2auth.service b/packages/st2/debian/st2auth.service deleted file mode 100644 index 54420192f..000000000 --- a/packages/st2/debian/st2auth.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=StackStorm service st2auth -After=network.target st2auth.socket -Requires=st2auth.socket - -[Service] -Type=simple -User=st2 -Group=st2 -Environment="DAEMON_ARGS=-k eventlet -b 127.0.0.1:9100 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.auth.gunicorn.conf --error-logfile /var/log/st2/st2auth.log" -EnvironmentFile=-/etc/default/st2auth -ExecStart=/opt/stackstorm/st2/bin/gunicorn st2auth.wsgi:application $DAEMON_ARGS -TimeoutSec=60 -PrivateTmp=true -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target diff --git a/packages/st2/debian/st2stream-generator b/packages/st2/debian/st2stream-generator index e7d82e0f4..e20b7baea 100755 --- a/packages/st2/debian/st2stream-generator +++ b/packages/st2/debian/st2stream-generator @@ -4,9 +4,9 @@ import logging import time import sys -ST2SVC="st2stream" -DEFAULT_IP="127.0.0.1" -DEFAULT_PORT="9102" +ST2SVC = "st2stream" +DEFAULT_IP = "127.0.0.1" +DEFAULT_PORT = "9101" ST2CFG = "/etc/st2/st2.conf" # Systemd passes 3 paths to a generator, normal_dir, early_dir, late_dir. @@ -37,7 +37,7 @@ section = ST2SVC[3:] bind_address = config[section].get("host", DEFAULT_IP) bind_port = config[section].get("port", DEFAULT_PORT) -contents = f"""[Unit] +socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} Description=StackStorm {ST2SVC} Socket. PartOf={ST2SVC}.service @@ -51,6 +51,31 @@ WantedBy=sockets.target """ with open(f"{NORMAL_DIR}/{ST2SVC}.socket", "w") as f: - f.write(contents) + f.write(socket_contents) -LOG.info(f"{ST2SVC} generated.") +LOG.info(f"{ST2SVC} socket generated.") + +unit_contents = f"""[Unit] +# Generated by {sys.argv[0]} at {time.asctime(time.localtime())} +Description=StackStorm service {ST2SVC} +After=network.target {ST2SVC}.socket +Requires={ST2SVC}.socket + +[Service] +Type=simple +User=st2 +Group=st2 +ExecStart=/opt/stackstorm/st2/bin/gunicorn {ST2SVC}.wsgi:application -k eventlet -b {bind_address}:{bind_port} --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.api.gunicorn.conf --error-logfile /var/log/st2/{ST2SVC}.log +TimeoutSec=60 +PrivateTmp=true +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +""" + +with open(f"{NORMAL_DIR}/{ST2SVC}.service", "w") as f: + f.write(unit_contents) + +LOG.info(f"{ST2SVC} unit generated") diff --git a/packages/st2/debian/st2stream.service b/packages/st2/debian/st2stream.service deleted file mode 100644 index ade3ba5dd..000000000 --- a/packages/st2/debian/st2stream.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=StackStorm service st2stream -After=network.target st2stream.socket -Requires=st2stream.socket - -[Service] -Type=simple -User=st2 -Group=st2 -Environment="DAEMON_ARGS=-k eventlet -b 127.0.0.1:9102 --workers 1 --threads 10 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.stream.gunicorn.conf --error-logfile /var/log/st2/st2stream.log" -EnvironmentFile=-/etc/default/st2stream -ExecStart=/opt/stackstorm/st2/bin/gunicorn st2stream.wsgi:application $DAEMON_ARGS -TimeoutSec=60 -PrivateTmp=true -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target diff --git a/packages/st2/rpm/st2.spec b/packages/st2/rpm/st2.spec index 9f31eb660..53a3156f1 100644 --- a/packages/st2/rpm/st2.spec +++ b/packages/st2/rpm/st2.spec @@ -124,9 +124,6 @@ Conflicts: st2common %attr(775, root, %{packs_group}) /opt/stackstorm/virtualenvs %{_unitdir}/st2actionrunner.service %{_unitdir}/%{worker_name}.service - %{_unitdir}/st2api.service - %{_unitdir}/st2stream.service - %{_unitdir}/st2auth.service %{_unitdir}/st2notifier.service %{_unitdir}/st2rulesengine.service %{_unitdir}/st2sensorcontainer.service From 6a0c31861d4c0cb8db0cea86c4df56a357f8e27d Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 15 Jul 2022 12:23:15 +0200 Subject: [PATCH 2/9] Enable services during post installation on Debian-like systems --- packages/st2/debian/postinst | 5 ++++- packages/st2/debian/rules | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/st2/debian/postinst b/packages/st2/debian/postinst index 510b49fbf..b6ef7873d 100644 --- a/packages/st2/debian/postinst +++ b/packages/st2/debian/postinst @@ -54,8 +54,11 @@ case "$1" in [ "$upgrading" = 1 ] || set_permissions "$SET_PERMS" rm -f $ST2_UPGRADESTAMP - # make sure that our socket generators run + # Reload systemd to run generators for unit and socket files. systemctl daemon-reload >/dev/null 2>&1 || true + + # Enable services created by systemd generator + systemctl enable st2api st2auth st2stream >/dev/null 2>&1 || true ;; abort-upgrade|abort-remove|abort-deconfigure) ;; diff --git a/packages/st2/debian/rules b/packages/st2/debian/rules index 3b61433bb..af1c32e87 100755 --- a/packages/st2/debian/rules +++ b/packages/st2/debian/rules @@ -47,9 +47,6 @@ override_dh_gencontrol: override_dh_installinit: dh_systemd_enable --name=st2actionrunner st2actionrunner.service install -p -m644 debian/st2actionrunner@.service debian/st2/lib/systemd/system/st2actionrunner@.service - dh_systemd_enable --name=st2api st2api.service - dh_systemd_enable --name=st2stream st2stream.service - dh_systemd_enable --name=st2auth st2auth.service dh_systemd_enable --name=st2notifier st2notifier.service dh_systemd_enable --name=st2rulesengine st2rulesengine.service dh_systemd_enable --name=st2sensorcontainer st2sensorcontainer.service From b7b018a820a87dd42079af9d0f6e6d65a50264dc Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 15 Jul 2022 12:41:39 +0200 Subject: [PATCH 3/9] Enable and start st2api/st2auth/st2stream services on RH based systems in post installation. --- packages/st2/debian/postinst | 1 + packages/st2/rpm/postinst_script.spec | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/st2/debian/postinst b/packages/st2/debian/postinst index b6ef7873d..9dd60e9ae 100644 --- a/packages/st2/debian/postinst +++ b/packages/st2/debian/postinst @@ -59,6 +59,7 @@ case "$1" in # Enable services created by systemd generator systemctl enable st2api st2auth st2stream >/dev/null 2>&1 || true + systemctl start st2api st2auth st2stream >/dev/null 2>&1 || true ;; abort-upgrade|abort-remove|abort-deconfigure) ;; diff --git a/packages/st2/rpm/postinst_script.spec b/packages/st2/rpm/postinst_script.spec index 65f63cf59..898f6ac9e 100644 --- a/packages/st2/rpm/postinst_script.spec +++ b/packages/st2/rpm/postinst_script.spec @@ -1,4 +1,8 @@ set -e -# make sure that our socket generators run +# Reload systemd to run generators for unit and socket files. systemctl daemon-reload >/dev/null 2>&1 || true + +# Enable services created by systemd generator +systemctl enable st2api st2auth st2stream >/dev/null 2>&1 || true +systemctl start st2api st2auth st2stream >/dev/null 2>&1 || true From a2df9cf3eb3438eeaca6aa43698acc03526745f7 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 15 Jul 2022 23:02:11 +0200 Subject: [PATCH 4/9] Fix default ports --- packages/st2/debian/st2auth-generator | 2 +- packages/st2/debian/st2stream-generator | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/st2/debian/st2auth-generator b/packages/st2/debian/st2auth-generator index 6f30f4c34..9a9a6f06b 100755 --- a/packages/st2/debian/st2auth-generator +++ b/packages/st2/debian/st2auth-generator @@ -6,7 +6,7 @@ import sys ST2SVC = "st2auth" DEFAULT_IP = "127.0.0.1" -DEFAULT_PORT = "9101" +DEFAULT_PORT = "9100" ST2CFG = "/etc/st2/st2.conf" # Systemd passes 3 paths to a generator, normal_dir, early_dir, late_dir. diff --git a/packages/st2/debian/st2stream-generator b/packages/st2/debian/st2stream-generator index e20b7baea..f811b4401 100755 --- a/packages/st2/debian/st2stream-generator +++ b/packages/st2/debian/st2stream-generator @@ -6,7 +6,7 @@ import sys ST2SVC = "st2stream" DEFAULT_IP = "127.0.0.1" -DEFAULT_PORT = "9101" +DEFAULT_PORT = "9102" ST2CFG = "/etc/st2/st2.conf" # Systemd passes 3 paths to a generator, normal_dir, early_dir, late_dir. From 0854611526a66c775c242865317bc433aa978650 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 16 Jul 2022 21:26:50 -0500 Subject: [PATCH 5/9] drop rpm service files --- packages/st2/rpm/st2api.service | 19 ------------------- packages/st2/rpm/st2auth.service | 19 ------------------- packages/st2/rpm/st2stream.service | 19 ------------------- 3 files changed, 57 deletions(-) delete mode 100644 packages/st2/rpm/st2api.service delete mode 100644 packages/st2/rpm/st2auth.service delete mode 100644 packages/st2/rpm/st2stream.service diff --git a/packages/st2/rpm/st2api.service b/packages/st2/rpm/st2api.service deleted file mode 100644 index 1b59b9b9c..000000000 --- a/packages/st2/rpm/st2api.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=StackStorm service st2api -After=network.target st2api.socket -Requires=st2api.socket - -[Service] -Type=simple -User=st2 -Group=st2 -Environment="DAEMON_ARGS=-k eventlet -b 127.0.0.1:9101 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.api.gunicorn.conf --error-logfile /var/log/st2/st2api.log" -EnvironmentFile=-/etc/sysconfig/st2api -ExecStart=/opt/stackstorm/st2/bin/gunicorn st2api.wsgi:application $DAEMON_ARGS -TimeoutSec=60 -PrivateTmp=true -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target diff --git a/packages/st2/rpm/st2auth.service b/packages/st2/rpm/st2auth.service deleted file mode 100644 index 260a78536..000000000 --- a/packages/st2/rpm/st2auth.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=StackStorm service st2auth -After=network.target st2auth.socket -Requires=st2auth.socket - -[Service] -Type=simple -User=st2 -Group=st2 -Environment="DAEMON_ARGS=-k eventlet -b 127.0.0.1:9100 --workers 1 --threads 1 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.auth.gunicorn.conf --error-logfile /var/log/st2/st2auth.log" -EnvironmentFile=-/etc/sysconfig/st2auth -ExecStart=/opt/stackstorm/st2/bin/gunicorn st2auth.wsgi:application $DAEMON_ARGS -TimeoutSec=60 -PrivateTmp=true -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target diff --git a/packages/st2/rpm/st2stream.service b/packages/st2/rpm/st2stream.service deleted file mode 100644 index 742cc2038..000000000 --- a/packages/st2/rpm/st2stream.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=StackStorm service st2stream -After=network.target st2stream.socket -Requires=st2stream.socket - -[Service] -Type=simple -User=st2 -Group=st2 -Environment="DAEMON_ARGS=-k eventlet -b 127.0.0.1:9102 --workers 1 --threads 10 --graceful-timeout 10 --timeout 30 --log-config /etc/st2/logging.stream.gunicorn.conf --error-logfile /var/log/st2/st2stream.log" -EnvironmentFile=-/etc/sysconfig/st2stream -ExecStart=/opt/stackstorm/st2/bin/gunicorn st2stream.wsgi:application $DAEMON_ARGS -TimeoutSec=60 -PrivateTmp=true -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target From b162672f82135f6c4a48b1feff7811a3f9170d14 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 16 Jul 2022 21:37:09 -0500 Subject: [PATCH 6/9] rpm helper should not try to install generated service files --- rpmspec/helpers.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpmspec/helpers.spec b/rpmspec/helpers.spec index f414900bd..ee7bcff2b 100644 --- a/rpmspec/helpers.spec +++ b/rpmspec/helpers.spec @@ -77,7 +77,7 @@ # %define service_install() \ for svc in %{?*}; do \ - install -D -p -m0644 %{SOURCE0}/rpm/$svc.service %{buildroot}%{_unitdir}/$svc.service \ + [ -f %{SOURCE0}/rpm/$svc.service ] && install -D -p -m0644 %{SOURCE0}/rpm/$svc.service %{buildroot}%{_unitdir}/$svc.service \ [ -f %{SOURCE0}/rpm/$svc.socket ] && install -D -p -m0644 %{SOURCE0}/rpm/$svc.socket %{buildroot}%{_unitdir}/$svc.socket \ done \ %{nil} From 9d49e83c92bf5f31d294f7c67d59ef2d09d33cad Mon Sep 17 00:00:00 2001 From: Carlos Date: Thu, 29 Sep 2022 18:17:32 +0200 Subject: [PATCH 7/9] Fix crash when st2.conf doesn't have the expected ini section. --- packages/st2/debian/st2api-generator | 4 ++-- packages/st2/debian/st2auth-generator | 4 ++-- packages/st2/debian/st2stream-generator | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/st2/debian/st2api-generator b/packages/st2/debian/st2api-generator index a118a8966..e00024f75 100755 --- a/packages/st2/debian/st2api-generator +++ b/packages/st2/debian/st2api-generator @@ -34,8 +34,8 @@ config = configparser.ConfigParser(strict=False) config.read(ST2CFG) section = ST2SVC[3:] -bind_address = config[section].get("host", DEFAULT_IP) -bind_port = config[section].get("port", DEFAULT_PORT) +bind_address = config.get(section, {}).get("host", DEFAULT_IP) +bind_port = config.get(section, {}).get("port", DEFAULT_PORT) socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} diff --git a/packages/st2/debian/st2auth-generator b/packages/st2/debian/st2auth-generator index 9a9a6f06b..afa0f458e 100755 --- a/packages/st2/debian/st2auth-generator +++ b/packages/st2/debian/st2auth-generator @@ -34,8 +34,8 @@ config = configparser.ConfigParser(strict=False) config.read(ST2CFG) section = ST2SVC[3:] -bind_address = config[section].get("host", DEFAULT_IP) -bind_port = config[section].get("port", DEFAULT_PORT) +bind_address = config.get(section, {}).get("host", DEFAULT_IP) +bind_port = config.get(section, {}).get("port", DEFAULT_PORT) socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} diff --git a/packages/st2/debian/st2stream-generator b/packages/st2/debian/st2stream-generator index f811b4401..98c091d98 100755 --- a/packages/st2/debian/st2stream-generator +++ b/packages/st2/debian/st2stream-generator @@ -34,8 +34,8 @@ config = configparser.ConfigParser(strict=False) config.read(ST2CFG) section = ST2SVC[3:] -bind_address = config[section].get("host", DEFAULT_IP) -bind_port = config[section].get("port", DEFAULT_PORT) +bind_address = config.get(section, {}).get("host", DEFAULT_IP) +bind_port = config.get(section, {}).get("port", DEFAULT_PORT) socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} From b89380c85a19fa2198490910d91194cda94815c1 Mon Sep 17 00:00:00 2001 From: Carlos Date: Thu, 29 Sep 2022 18:56:32 +0200 Subject: [PATCH 8/9] fix syntax for ConfigParser get(). --- packages/st2/debian/st2api-generator | 4 ++-- packages/st2/debian/st2auth-generator | 4 ++-- packages/st2/debian/st2stream-generator | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/st2/debian/st2api-generator b/packages/st2/debian/st2api-generator index e00024f75..fcdf7de6a 100755 --- a/packages/st2/debian/st2api-generator +++ b/packages/st2/debian/st2api-generator @@ -34,8 +34,8 @@ config = configparser.ConfigParser(strict=False) config.read(ST2CFG) section = ST2SVC[3:] -bind_address = config.get(section, {}).get("host", DEFAULT_IP) -bind_port = config.get(section, {}).get("port", DEFAULT_PORT) +bind_address = config.get(section, "host", fallback=DEFAULT_IP) +bind_port = config.get(section, "port", fallback=DEFAULT_PORT) socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} diff --git a/packages/st2/debian/st2auth-generator b/packages/st2/debian/st2auth-generator index afa0f458e..0a56b6f35 100755 --- a/packages/st2/debian/st2auth-generator +++ b/packages/st2/debian/st2auth-generator @@ -34,8 +34,8 @@ config = configparser.ConfigParser(strict=False) config.read(ST2CFG) section = ST2SVC[3:] -bind_address = config.get(section, {}).get("host", DEFAULT_IP) -bind_port = config.get(section, {}).get("port", DEFAULT_PORT) +bind_address = config.get(section, "host", fallback=DEFAULT_IP) +bind_port = config.get(section, "port", fallback=DEFAULT_PORT) socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} diff --git a/packages/st2/debian/st2stream-generator b/packages/st2/debian/st2stream-generator index 98c091d98..31474edee 100755 --- a/packages/st2/debian/st2stream-generator +++ b/packages/st2/debian/st2stream-generator @@ -34,8 +34,8 @@ config = configparser.ConfigParser(strict=False) config.read(ST2CFG) section = ST2SVC[3:] -bind_address = config.get(section, {}).get("host", DEFAULT_IP) -bind_port = config.get(section, {}).get("port", DEFAULT_PORT) +bind_address = config.get(section, "host", fallback=DEFAULT_IP) +bind_port = config.get(section, "port", fallback=DEFAULT_PORT) socket_contents = f"""[Unit] # Generated by {sys.argv[0]} at {time.asctime(time.localtime())} From 11c3c761d99341079451d6f919bfba05a8175b16 Mon Sep 17 00:00:00 2001 From: Carlos Date: Mon, 10 Oct 2022 08:45:37 +0200 Subject: [PATCH 9/9] Remove attempt to restart services via post installation script for RPM packages. --- packages/st2/rpm/postinst_script.spec | 6 +----- packages/st2/rpm/st2.spec | 5 +++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/st2/rpm/postinst_script.spec b/packages/st2/rpm/postinst_script.spec index 898f6ac9e..d49c41799 100644 --- a/packages/st2/rpm/postinst_script.spec +++ b/packages/st2/rpm/postinst_script.spec @@ -1,8 +1,4 @@ set -e # Reload systemd to run generators for unit and socket files. -systemctl daemon-reload >/dev/null 2>&1 || true - -# Enable services created by systemd generator -systemctl enable st2api st2auth st2stream >/dev/null 2>&1 || true -systemctl start st2api st2auth st2stream >/dev/null 2>&1 || true +systemctl daemon-reload diff --git a/packages/st2/rpm/st2.spec b/packages/st2/rpm/st2.spec index 53a3156f1..a2e60b1c3 100644 --- a/packages/st2/rpm/st2.spec +++ b/packages/st2/rpm/st2.spec @@ -85,11 +85,12 @@ Conflicts: st2common %pre %include rpm/preinst_script.spec +# Execute postinst_script before start post install services so the generators have created .service and .socket files. %post - %service_post st2actionrunner st2api st2stream st2auth st2notifier st2workflowengine + %include rpm/postinst_script.spec + %service_post st2api st2stream st2auth st2actionrunner st2notifier st2workflowengine %service_post st2rulesengine st2timersengine st2sensorcontainer st2garbagecollector %service_post st2scheduler - %include rpm/postinst_script.spec %preun %service_preun st2actionrunner %{worker_name} st2api st2stream st2auth st2notifier st2workflowengine