#!/usr/bin/env python3 import bjoern import os import socket import traceback from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") app = get_wsgi_application() NUM_WORKERS = 1 worker_pids = [] socket_path = "/var/run/reinheit/reinheit.sock" try: os.unlink(socket_path) except OSError: if os.path.exists(socket_path): os.remove(socket_path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.bind(socket_path) sock.listen() print("Setting access mode to 777") os.chmod(socket_path, 0o777) try: print(f"Serving reinheit via {socket_path}") bjoern.server_run(sock, app) except Exception: traceback.print_exc() try: sock.close() except Exception: traceback.print_exc() try: os.remove(socket_path) except Exception: traceback.print_exc()