[Unit]
Description=RadAngel gamma spectrometer
After=multi-user.target

[Service]
Type=simple

User=www-data
Group=www-data

Environment=EVENT_FILE=/tmp/event.tsv
Environment=STATS_FILE=/tmp/stats.tsv
#EnvironmentFile=/etc/default/radangel

PermissionsStartOnly=true
ExecStartPre=/usr/bin/touch ${EVENT_FILE}
ExecStartPre=/usr/bin/touch ${STATS_FILE}
ExecStartPre=/bin/chown www-data:www-data ${EVENT_FILE}
ExecStartPre=/bin/chown www-data:www-data ${STATS_FILE}
ExecStartPre=/bin/chmod o+r ${EVENT_FILE}
ExecStartPre=/bin/chmod o+r ${STATS_FILE}

WorkingDirectory=/tmp
ExecStart=/usr/bin/radangel --verbose \
	--event ${EVENT_FILE}              \
	--stats ${STATS_FILE}

NoNewPrivileges=true
RestartSec=5
Restart=on-failure

[Install]
WantedBy=multi-user.target


