mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-10 06:34:16 +00:00
make archivebox server spawn daphne process instead of runserver
This commit is contained in:
parent
f6ca48835a
commit
6e2ddc14df
1 changed files with 29 additions and 3 deletions
|
@ -4,13 +4,16 @@ import os
|
|||
import sys
|
||||
import shutil
|
||||
import platform
|
||||
from django.utils import timezone
|
||||
import subprocess
|
||||
|
||||
from typing import Dict, List, Optional, Iterable, IO, Union
|
||||
from pathlib import Path
|
||||
from datetime import date, datetime
|
||||
|
||||
from typing import Dict, List, Optional, Iterable, IO, Union
|
||||
from crontab import CronTab, CronSlices
|
||||
|
||||
from django.db.models import QuerySet
|
||||
from django.utils import timezone
|
||||
|
||||
from .cli import (
|
||||
list_subcommands,
|
||||
|
@ -1346,7 +1349,30 @@ def server(runserver_args: Optional[List[str]]=None,
|
|||
config.SHOW_PROGRESS = False
|
||||
config.DEBUG = config.DEBUG or debug
|
||||
|
||||
if reload or debug:
|
||||
call_command("runserver", *runserver_args)
|
||||
else:
|
||||
host = '127.0.0.1'
|
||||
port = '8000'
|
||||
|
||||
try:
|
||||
host_and_port = [arg for arg in runserver_args if arg.replace('.', '').replace(':', '').isdigit()][0]
|
||||
if ':' in host_and_port:
|
||||
host, port = host_and_port.split(':')
|
||||
else:
|
||||
if '.' in host_and_port:
|
||||
host = host_and_port
|
||||
else:
|
||||
port = host_and_port
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
try:
|
||||
subprocess.run(['daphne', '--bind', host, '--port', port, 'archivebox.core.asgi:application'])
|
||||
except (SystemExit, KeyboardInterrupt):
|
||||
pass
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
@enforce_types
|
||||
|
|
Loading…
Reference in a new issue