add quick-init option to skip reimporting all snapshot dirs on init
This commit is contained in:
parent
e61e12c889
commit
3c3bae02d2
4 changed files with 56 additions and 42 deletions
|
@ -27,11 +27,17 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Ignore unrecognized files in current directory and initialize anyway',
|
help='Ignore unrecognized files in current directory and initialize anyway',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--quick', '-q',
|
||||||
|
action='store_true',
|
||||||
|
help='Run any updates or migrations without rechecking all snapshot dirs',
|
||||||
|
)
|
||||||
command = parser.parse_args(args or ())
|
command = parser.parse_args(args or ())
|
||||||
reject_stdin(__command__, stdin)
|
reject_stdin(__command__, stdin)
|
||||||
|
|
||||||
init(
|
init(
|
||||||
force=command.force,
|
force=command.force,
|
||||||
|
quick=command.quick,
|
||||||
out_dir=pwd or OUTPUT_DIR,
|
out_dir=pwd or OUTPUT_DIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,12 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--init',
|
'--init',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='Run archivebox init before starting the server',
|
help='Run a full archivebox init/upgrade before starting the server',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--quick-init', '-i',
|
||||||
|
action='store_true',
|
||||||
|
help='Run quick archivebox init/upgrade before starting the server',
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--createsuperuser',
|
'--createsuperuser',
|
||||||
|
@ -56,6 +61,7 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
||||||
reload=command.reload,
|
reload=command.reload,
|
||||||
debug=command.debug,
|
debug=command.debug,
|
||||||
init=command.init,
|
init=command.init,
|
||||||
|
quick_init=command.quick_init,
|
||||||
createsuperuser=command.createsuperuser,
|
createsuperuser=command.createsuperuser,
|
||||||
out_dir=pwd or OUTPUT_DIR,
|
out_dir=pwd or OUTPUT_DIR,
|
||||||
)
|
)
|
||||||
|
|
|
@ -263,7 +263,7 @@ def run(subcommand: str,
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def init(force: bool=False, out_dir: Path=OUTPUT_DIR) -> None:
|
def init(force: bool=False, quick: bool=False, out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
"""Initialize a new ArchiveBox collection in the current directory"""
|
"""Initialize a new ArchiveBox collection in the current directory"""
|
||||||
|
|
||||||
from core.models import Snapshot
|
from core.models import Snapshot
|
||||||
|
@ -345,6 +345,7 @@ def init(force: bool=False, out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
all_links = load_main_index(out_dir=out_dir, warn=False)
|
all_links = load_main_index(out_dir=out_dir, warn=False)
|
||||||
print(' √ Loaded {} links from existing main index.'.format(all_links.count()))
|
print(' √ Loaded {} links from existing main index.'.format(all_links.count()))
|
||||||
|
|
||||||
|
if not quick:
|
||||||
# Links in data folders that dont match their timestamp
|
# Links in data folders that dont match their timestamp
|
||||||
fixed, cant_fix = fix_invalid_folder_locations(out_dir=out_dir)
|
fixed, cant_fix = fix_invalid_folder_locations(out_dir=out_dir)
|
||||||
if fixed:
|
if fixed:
|
||||||
|
@ -1063,14 +1064,15 @@ def server(runserver_args: Optional[List[str]]=None,
|
||||||
reload: bool=False,
|
reload: bool=False,
|
||||||
debug: bool=False,
|
debug: bool=False,
|
||||||
init: bool=False,
|
init: bool=False,
|
||||||
|
quick_init: bool=False,
|
||||||
createsuperuser: bool=False,
|
createsuperuser: bool=False,
|
||||||
out_dir: Path=OUTPUT_DIR) -> None:
|
out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
"""Run the ArchiveBox HTTP server"""
|
"""Run the ArchiveBox HTTP server"""
|
||||||
|
|
||||||
runserver_args = runserver_args or []
|
runserver_args = runserver_args or []
|
||||||
|
|
||||||
if init:
|
if init or quick_init:
|
||||||
run_subcommand('init', stdin=None, pwd=out_dir)
|
run_subcommand('init', quick=quick_init, stdin=None, pwd=out_dir)
|
||||||
|
|
||||||
if createsuperuser:
|
if createsuperuser:
|
||||||
run_subcommand('manage', subcommand_args=['createsuperuser'], pwd=out_dir)
|
run_subcommand('manage', subcommand_args=['createsuperuser'], pwd=out_dir)
|
||||||
|
|
|
@ -13,7 +13,7 @@ services:
|
||||||
archivebox:
|
archivebox:
|
||||||
# build: .
|
# build: .
|
||||||
image: ${DOCKER_IMAGE:-archivebox/archivebox:latest}
|
image: ${DOCKER_IMAGE:-archivebox/archivebox:latest}
|
||||||
command: server 0.0.0.0:8000
|
command: server --quick-init 0.0.0.0:8000
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
ports:
|
ports:
|
||||||
|
|
Loading…
Add table
Reference in a new issue