[Unit]
Description=Freva rest API server
After=network.target
Wants=network.target

[Service]
Type=simple
PermissionsStartOnly=true
NoNewPrivileges=true
KillSignal=SIGTERM
{% if debug | default(false) %}
ExecStart={{ bash_cmd }} -c "{{ conda_path }}/bin/freva-rest-server --dev"
{% else %}
ExecStart={{bash_cmd }} -c "{{ conda_path }}/bin/freva-rest-server"
{% endif %}
Environment="PATH={{conda_path}}/bin:{{ ansible_env.PATH }}"
EnvironmentFile={{ data_dir }}/config/service.env
Restart=on-failure
RestartSec=5
StartLimitBurst=5
UMask=007
ReadWritePaths={{conda_path }}
{% if (ansible_become == true and ansible_become_user == 'root') or ansible_user == 'root' %}
ProtectHome=true
ProtectSystem=full
User={{uid}}
Group={{gid}}
{% endif %}


[Install]
WantedBy=multi-user.target
