[Unit]
Description=Start websockify
After=multi-user.target

[Service]
Type=forking

User=www-data
Group=www-data

Environment=LISTEN_HOST=127.0.0.1
Environment=LISTEN_PORT=5800
Environment=TARGET_HOST=127.0.0.1
Environment=TARGET_PORT=5900
#EnvironmentFile=/etc/default/websockify

PIDFile=/var/run/websockify.pid
PermissionsStartOnly=true
ExecStartPre=/bin/sh -c '\
	touch /var/run/websockify.pid; \
	chown www-data:www-data /var/run/websockify.pid'
WorkingDirectory=/tmp
ExecStart=/opt/websockify/websockify --daemon --pid /var/run/websockify.pid \
	${LISTEN_HOST}:${LISTEN_PORT} \
	${TARGET_HOST}:${TARGET_PORT}

NoNewPrivileges=true
RestartSec=5
Restart=on-failure


[Install]
WantedBy=multi-user.target


