mirror of
https://github.com/YunoHost-Apps/mattermost_ynh.git
synced 2024-09-03 19:36:29 +02:00
conf: use a Type=notify systemd service
Starting from Mattermost 4.8, the server process sends a systemd notification when it is ready to accept network connections. Thus we don't need to explicitely wait for the port to be open in the service. As a bonus, by removing the hack, we don't need to replace `__PORT__` in the service anymore–which means the associated script helper can be removed too.
This commit is contained in:
parent
0ad492156a
commit
331fcce8c5
4 changed files with 3 additions and 28 deletions
|
@ -5,14 +5,8 @@ After=mysql.service
|
|||
Requires=mysql.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Type=notify
|
||||
ExecStart=__FINALPATH__/bin/platform
|
||||
# HACK: Wait for Mattermost port to be open before declaring the service to be launched successfully.
|
||||
# This avoids to report the service as launched even when it crashes a few milliseconds after start.
|
||||
#
|
||||
# TODO: improve mattermost to send a STARTED notification, and
|
||||
# switch the service to 'Type=notify' instead.
|
||||
ExecStartPost=/usr/bin/timeout 10 /bin/sh -c 'while ! nc -z localhost __PORT__; do sleep 0.2; done'
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
WorkingDirectory=__FINALPATH__
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Add a systemd configuration using ynh_add_systemd_config,
|
||||
# by replacing __PORT__ with the $port variable value.
|
||||
mattermost_add_systemd_config () {
|
||||
local config_path="../conf"
|
||||
|
||||
# Replace variables in the systemd template config file
|
||||
sed -i'.template' "s/__PORT__/$port/g" "$config_path/systemd.service"
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
# Restore the original configuration template
|
||||
rm "$config_path/systemd.service"
|
||||
mv "$config_path/systemd.service.template" "$config_path/systemd.service"
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -168,7 +167,7 @@ ynh_add_nginx_config
|
|||
# SYSTEMD CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
mattermost_add_systemd_config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
@ -132,7 +131,7 @@ ynh_add_nginx_config
|
|||
# SYSTEMD CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
mattermost_add_systemd_config
|
||||
ynh_add_systemd_config
|
||||
|
||||
#=================================================
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
|
|
Loading…
Add table
Reference in a new issue