Skip to content
Open
Show file tree
Hide file tree
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
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 @@ -39,9 +39,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.

4 changes: 2 additions & 2 deletions packages/st2/rpm/postinst_script.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set -e

# make sure that our socket generators run
systemctl daemon-reload >/dev/null 2>&1 || true
# Reload systemd to run generators for unit and socket files.
systemctl daemon-reload
8 changes: 3 additions & 5 deletions packages/st2/rpm/st2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,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
Expand Down Expand Up @@ -132,9 +133,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 @@ -76,7 +76,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