Coverage for frappe_manager / commands / start.py: 62%

21 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-07-02 18:13 +0530

1from typing import Annotated 

2 

3import typer 

4from typer_examples import example 

5 

6from frappe_manager.commands import check_bench_migration_required 

7from frappe_manager.output_manager import get_global_output_handler, spinner 

8from frappe_manager.site_manager.site import Bench 

9from frappe_manager.utils.callbacks import ( 

10 sitename_callback, 

11 sites_autocompletion_callback, 

12) 

13 

14 

15@example( 

16 "Start bench containers", 

17 "{benchname}", 

18 detail="Starts all containers for the specified bench. Useful to bring a bench up after stopping or system reboot.", 

19 benchname="mybench", 

20) 

21@example( 

22 "Force recreate containers", 

23 "{benchname} --force", 

24 detail="Recreates containers even if they already exist; use when container images or configuration changed.", 

25 benchname="mybench", 

26) 

27@example( 

28 "Start and reconfigure workers", 

29 "{benchname} --reconfigure-workers", 

30 detail="Starts the bench and reconfigures worker processes to pick up configuration changes.", 

31 benchname="mybench", 

32) 

33@example( 

34 "Start with supervisor reconfiguration", 

35 "{benchname} --reconfigure-supervisor", 

36 detail="Reconfigures the supervisor process manager during start to update process definitions.", 

37 benchname="mybench", 

38) 

39@example( 

40 "Start and sync dev packages", 

41 "{benchname} --sync-dev-packages", 

42 detail="Synchronizes development packages after starting; useful in development workflows.", 

43 benchname="mybench", 

44) 

45def start( 

46 ctx: typer.Context, 

47 benchname: Annotated[ 

48 str | None, 

49 typer.Argument( 

50 help="Name of the bench.", 

51 autocompletion=sites_autocompletion_callback, 

52 callback=sitename_callback, 

53 ), 

54 ] = None, 

55 force: Annotated[bool, typer.Option("--force", "-f", help="Recreate containers")] = False, 

56 reconfigure_supervisor: Annotated[ 

57 bool, 

58 typer.Option("--reconfigure-supervisor", help="Reconfigure supervisor"), 

59 ] = False, 

60 reconfigure_common_site_config: Annotated[ 

61 bool, 

62 typer.Option("--reconfigure-common-site-config", help="Reconfigure site config"), 

63 ] = False, 

64 reconfigure_workers: Annotated[bool, typer.Option("--reconfigure-workers", help="Reconfigure workers")] = False, 

65 include_default_workers: Annotated[bool, typer.Option(help="Include default workers")] = True, 

66 include_custom_workers: Annotated[bool, typer.Option(help="Include custom workers")] = True, 

67 sync_dev_packages: Annotated[bool, typer.Option("--sync-dev-packages", help="Sync dev packages")] = False, 

68): 

69 """ 

70 Start a bench. 

71 

72 Starts all containers for the specified bench. Reconfigure flags allow updating process and worker settings. 

73 """ 

74 

75 check_bench_migration_required(benchname) 

76 

77 services_manager = ctx.obj["services"] 

78 verbose = ctx.obj["verbose"] 

79 logger = ctx.obj.get("logger") 

80 

81 output = get_global_output_handler() 

82 bench = Bench.get_object(benchname, services_manager, logger=logger, output_handler=output) 

83 

84 with spinner(output, f"Starting {benchname}"): 

85 bench.start( 

86 force=force, 

87 reconfigure_workers=reconfigure_workers, 

88 include_default_workers=include_default_workers, 

89 include_custom_workers=include_custom_workers, 

90 reconfigure_common_site_config=reconfigure_common_site_config, 

91 reconfigure_supervisor=reconfigure_supervisor, 

92 sync_dev_packages=sync_dev_packages, 

93 )