# NOTE: This file is managed by Puppet
# Systemd unit for <%= @title %>
[Unit]
Description="<%= @title %> service"
After=network.target

[Service]
# up ulimit -n a bit
LimitNOFILE=<%= @no_file %>
User=<%= @title %>
Group=<%= @title %>
Environment="NODE_PATH=/srv/deployment/<%= @repo %>/node_modules"
Environment="<%= @title.gsub(/[^a-zA-Z0-9_]/, '_').upcase %>_PORT=<%= @port %>"
<%- if @environment && !@environment.empty? -%>
<%- @environment.each do | variable, value | -%>
Environment="<%= variable.upcase %>=<%= value %>"
<%- end -%>
<%- end -%>
SyslogIdentifier=<%= @title %>
<% if @init_restart -%>
Restart=always
RestartSec=2s
<% end -%>
# wait 60 seconds for a graceful restart before killing the master
TimeoutStopSec=60
WorkingDirectory=/srv/deployment/<%= @repo %>
ExecStart=/usr/bin/firejail --blacklist=/root --blacklist=/home --caps --seccomp /usr/bin/nodejs <%= @starter_script %> -c /etc/<%= @title %>/config.yaml

[Install]
WantedBy=multi-user.target
