[Unit]
Description=Kong server
After=postgrest.service gotrue.service adminapi.service
Wants=postgrest.service gotrue.service adminapi.service
Conflicts=envoy.service

# Ensures that Kong service is stopped before Envoy service is started
Before=envoy.service

[Service]
Type=forking
ExecStart=/usr/local/bin/kong start -c /etc/kong/kong.conf
ExecReload=/usr/local/bin/kong reload -c /etc/kong/kong.conf
ExecStop=/usr/local/bin/kong quit
User=kong
EnvironmentFile=/etc/kong/kong.env
Slice=services.slice
Restart=always
RestartSec=3
LimitNOFILE=100000

# The kong user is unprivileged and thus not permitted to bind on ports < 1024
# Via systemd we grant the process a set of privileges to bind to 80/443
# See http://archive.vn/36zJU
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
