Coverage for gws-app/gws/server/cli.py: 0%

29 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Command-line server commands.""" 

2 

3from typing import Optional 

4 

5import gws 

6 

7from . import control 

8 

9 

10class Params(gws.CliParams): 

11 """Parameters for server commands.""" 

12 config: Optional[str] 

13 """Configuration file.""" 

14 manifest: Optional[str] 

15 """Manifest file.""" 

16 

17 

18class ConfigTestParams(gws.CliParams): 

19 """Parameters for the config test command.""" 

20 config: Optional[str] 

21 """Configuration file.""" 

22 manifest: Optional[str] 

23 """Manifest file.""" 

24 dirs: Optional[str] 

25 """Directories to watch for changes, ``/data`` by default.""" 

26 watch: Optional[bool] 

27 """Repeat the test whenever a file in the watched directories changes.""" 

28 parse: Optional[bool] 

29 """Only parse the configuration, do not configure the objects.""" 

30 

31 

32@gws.ext.object.cli('server') 

33class Object(gws.Node): 

34 """Command-line commands for starting, reloading and configuring the server.""" 

35 

36 @gws.ext.command.cli('serverStart') 

37 def do_start(self, p: Params): 

38 """Configure and start the server.""" 

39 

40 control.start(p.manifest, p.config) 

41 

42 @gws.ext.command.cli('serverReload') 

43 def do_reload(self, p: Params): 

44 """Reload the server without reconfiguring.""" 

45 

46 control.reload_all() 

47 

48 @gws.ext.command.cli('serverReconfigure') 

49 def do_reconfigure(self, p: Params): 

50 """Reconfigure and reload the server.""" 

51 

52 control.reconfigure(p.manifest, p.config) 

53 

54 @gws.ext.command.cli('serverConfigure') 

55 def do_configure(self, p: Params): 

56 """Configure the server without reloading.""" 

57 

58 control.configure_and_store(p.manifest, p.config) 

59 

60 @gws.ext.command.cli('serverConfigtest') 

61 def do_configtest(self, p: ConfigTestParams): 

62 """Test the configuration and report errors, optionally watching for changes.""" 

63 

64 control.config_test( 

65 p.manifest, 

66 p.config, 

67 p.dirs, 

68 with_parse_only=p.parse, 

69 with_watch=p.watch, 

70 )