Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
6 changes: 5 additions & 1 deletion packages/st2/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ 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
systemctl start st2api st2auth st2stream >/dev/null 2>&1 || true
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
Expand Down
3 changes: 0 additions & 3 deletions packages/st2/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 30 additions & 5 deletions packages/st2/debian/st2api-generator
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ 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, "host", fallback=DEFAULT_IP)
bind_port = config.get(section, "port", fallback=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
Expand All @@ -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")
19 changes: 0 additions & 19 deletions packages/st2/debian/st2api.service

This file was deleted.

41 changes: 33 additions & 8 deletions packages/st2/debian/st2auth-generator
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "9100"
ST2CFG = "/etc/st2/st2.conf"

# Systemd passes 3 paths to a generator, normal_dir, early_dir, late_dir.
Expand Down Expand Up @@ -34,10 +34,10 @@ 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, "host", fallback=DEFAULT_IP)
bind_port = config.get(section, "port", fallback=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
Expand All @@ -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")
19 changes: 0 additions & 19 deletions packages/st2/debian/st2auth.service

This file was deleted.

41 changes: 33 additions & 8 deletions packages/st2/debian/st2stream-generator
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "9102"
ST2CFG = "/etc/st2/st2.conf"

# Systemd passes 3 paths to a generator, normal_dir, early_dir, late_dir.
Expand Down Expand Up @@ -34,10 +34,10 @@ 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, "host", fallback=DEFAULT_IP)
bind_port = config.get(section, "port", fallback=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
Expand All @@ -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")
19 changes: 0 additions & 19 deletions packages/st2/debian/st2stream.service

This file was deleted.

6 changes: 5 additions & 1 deletion packages/st2/rpm/postinst_script.spec
Original file line number Diff line number Diff line change
@@ -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
Copy link
Copy Markdown
Member

@cognifloyd cognifloyd Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the test error for EL distros:

I think this is already handled by the %post macro which uses the %service_post helper. That runs:

systemctl --no-reload enable %{?*} >/dev/null 2>&1 || : \

What if you remove the output redirection in the %service_post macro helper? Then maybe we'll see if there's an error. And maybe remove it here too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a worker timeout for gunicorn on EL7, but I don't think that's the cause of the services failing to start for the RPM based distros. I still don't see any errors in the logs that indicate why the service is not enabled and started.

3 changes: 0 additions & 3 deletions packages/st2/rpm/st2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions packages/st2/rpm/st2api.service

This file was deleted.

19 changes: 0 additions & 19 deletions packages/st2/rpm/st2auth.service

This file was deleted.

19 changes: 0 additions & 19 deletions packages/st2/rpm/st2stream.service

This file was deleted.

2 changes: 1 addition & 1 deletion rpmspec/helpers.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down