mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 14:44:29 -04: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 sys
|
||||||
import shutil
|
import shutil
|
||||||
import platform
|
import platform
|
||||||
from django.utils import timezone
|
import subprocess
|
||||||
|
|
||||||
|
from typing import Dict, List, Optional, Iterable, IO, Union
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
|
|
||||||
from typing import Dict, List, Optional, Iterable, IO, Union
|
|
||||||
from crontab import CronTab, CronSlices
|
from crontab import CronTab, CronSlices
|
||||||
|
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from .cli import (
|
from .cli import (
|
||||||
list_subcommands,
|
list_subcommands,
|
||||||
|
@ -1346,7 +1349,30 @@ def server(runserver_args: Optional[List[str]]=None,
|
||||||
config.SHOW_PROGRESS = False
|
config.SHOW_PROGRESS = False
|
||||||
config.DEBUG = config.DEBUG or debug
|
config.DEBUG = config.DEBUG or debug
|
||||||
|
|
||||||
call_command("runserver", *runserver_args)
|
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
|
@enforce_types
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue