"""gunicorn WSGI server configuration."""
import os
from multiprocessing import cpu_count


PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
LOGS_DIR = os.path.join(PROJECT_DIR, 'logs')


if not os.path.exists(LOGS_DIR):
    os.makedirs(LOGS_DIR)


def max_workers():
    return cpu_count() * 2 + 1

bind = '127.0.0.1:9001'
timeout = 60
max_requests = 1000
worker_class = 'gevent'
workers = max_workers()

accesslog = os.path.join(LOGS_DIR, 'access.log')
errorlog = os.path.join(LOGS_DIR, 'error.log')