git - alex wennerberg
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
#!/sbin/openrc-run
name="3cardblind"
description="3 Card Blind Flask Web Application"

user="web"
command="/usr/bin/gunicorn"
command_args="--bind 0.0.0.0:5000 --workers 4 app:app"
command_background="yes"
command_user="${user}"
directory="/opt/3cardblind"
pidfile="/var/run/${name}.pid"
output_log="/var/log/3cardblind.log"
error_log="/var/log/3cardblind.log"

export FLASK_ENV=production

start_pre() {
    touch "${output_log}"
    chown "${user}:${user}" "${output_log}"
    # Initialize the materialized view
    cd "${directory}"
    su -s /bin/sh -c "python3 -c 'from app import init_db; init_db()'" "${user}"
}

depend() {
    need net
}