diff --git a/ansible/blog.service b/ansible/blog.service new file mode 100644 index 0000000..8b8f7b1 --- /dev/null +++ b/ansible/blog.service @@ -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"