This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/ansible/blog.service

34 lines
816 B
Desktop File

#!/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="127.0.0.1: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
/srv/blogvenv/bin/python /srv/blog/manage.py assets build --manifest django
}
run_rc_command "$1"