description "Coriolis API service"
author "Cloudbase Solutions <info@cloudbasesolutions.com>"

start on runlevel [2345]
stop on runlevel [!2345]

chdir /var/run

respawn
respawn limit 20 5
limit nofile 65535 65535

pre-start script
	for i in lock run log lib ; do
		mkdir -p /var/$i/coriolis
		chown coriolis /var/$i/coriolis
	done
end script

script
	[ -x "/usr/local/bin/coriolis-api" ] || exit 0

	exec start-stop-daemon --start --chdir /var/lib/coriolis \
		--chuid coriolis:coriolis --make-pidfile --pidfile /var/run/coriolis/coriolis-api.pid \
		--exec /usr/local/bin/coriolis-api -- --config-file=/etc/coriolis/coriolis.conf --log-file=coriolis-api.log
end script

