Add FreeBSD service

This commit is contained in:
Gabriel Augendre 2020-11-12 11:48:21 +01:00
parent ae3912299b
commit 83e2095b12
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4

33
ansible/blog.service Normal file
View file

@ -0,0 +1,33 @@
#!/bin/sh
# PROVIDE: blog
# REQUIRE: LOGIN NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name=blog
rcvar="blog_enable"
load_rc_config $name
: ${blog_enable="NO"}
: ${blog_listen_addr="0.0.0.0:8000"}
pidfile="/var/run/${name}.pid"
logfile="/var/log/${name}.log"
blog_env_file="/srv/blog/.env"
command_interpreter="/srv/blogvenv/bin/python"
command="/srv/blogvenv/bin/gunicorn"
blog_flags="-D --chdir /srv/blog -b ${blog_listen_addr} --log-file ${logfile} --pid ${pidfile}"
command_args="blog.wsgi"
start_precmd="${name}_prestart"
blog_prestart()
{
. /srv/blog/.env
yes yes | /srv/blogvenv/bin/python /srv/blog/manage.py migrate
/srv/blogvenv/bin/python /srv/blog/manage.py collectstatic --noinput --clear
}
run_rc_command "$1"