mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
Some checks failed
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Build Debian package / build (amd64) (push) Has been cancelled
Build Debian package / build (arm64) (push) Has been cancelled
Build Docker image / buildx (push) Has been cancelled
Deploy static content to Pages / deploy (push) Has been cancelled
Build GitHub Pages website / build (push) Has been cancelled
Run linters / lint (push) Has been cancelled
Build Pip package / build (push) Has been cancelled
Parallel Tests / Discover test files (push) Has been cancelled
Parallel Tests / Plugin tests (push) Has been cancelled
Run tests / python_tests (ubuntu-22.04, 3.13) (push) Has been cancelled
Run tests / docker_tests (push) Has been cancelled
Build Debian package / test (amd64, ubuntu-24.04) (push) Has been cancelled
Build Debian package / test (arm64, ubuntu-24.04-arm) (push) Has been cancelled
Build Debian package / release (push) Has been cancelled
Build GitHub Pages website / deploy (push) Has been cancelled
Parallel Tests / ${{ matrix.test.name }} (push) Has been cancelled
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
__package__ = 'archivebox.core'
|
|
|
|
from django.apps import AppConfig
|
|
import os
|
|
|
|
|
|
class CoreConfig(AppConfig):
|
|
name = 'archivebox.core'
|
|
label = 'core'
|
|
|
|
def ready(self):
|
|
"""Register the archivebox.core.admin_site as the main django admin site"""
|
|
import sys
|
|
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
|
|
|
|
from archivebox.core.admin_site import register_admin_site
|
|
register_admin_site()
|
|
|
|
# Import models to register state machines with the registry
|
|
# Skip during makemigrations to avoid premature state machine access
|
|
if 'makemigrations' not in sys.argv:
|
|
from archivebox.core import models # noqa: F401
|
|
|
|
pidfile = os.environ.get('ARCHIVEBOX_RUNSERVER_PIDFILE')
|
|
if pidfile:
|
|
should_write_pid = True
|
|
if os.environ.get('ARCHIVEBOX_AUTORELOAD') == '1':
|
|
should_write_pid = os.environ.get(DJANGO_AUTORELOAD_ENV) == 'true'
|
|
if should_write_pid:
|
|
try:
|
|
with open(pidfile, 'w') as handle:
|
|
handle.write(str(os.getpid()))
|
|
except Exception:
|
|
pass
|
|
|
|
def _should_prepare_runtime() -> bool:
|
|
if os.environ.get('ARCHIVEBOX_RUNSERVER') == '1':
|
|
if os.environ.get('ARCHIVEBOX_AUTORELOAD') == '1':
|
|
return os.environ.get(DJANGO_AUTORELOAD_ENV) == 'true'
|
|
return True
|
|
return False
|
|
|
|
if _should_prepare_runtime():
|
|
from archivebox.machine.models import Process, Machine
|
|
|
|
Process.cleanup_stale_running()
|
|
Machine.current()
|