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
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Command-line server commands."""
3from typing import Optional
5import gws
7from . import control
10class Params(gws.CliParams):
11 """Parameters for server commands."""
12 config: Optional[str]
13 """Configuration file."""
14 manifest: Optional[str]
15 """Manifest file."""
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."""
32@gws.ext.object.cli('server')
33class Object(gws.Node):
34 """Command-line commands for starting, reloading and configuring the server."""
36 @gws.ext.command.cli('serverStart')
37 def do_start(self, p: Params):
38 """Configure and start the server."""
40 control.start(p.manifest, p.config)
42 @gws.ext.command.cli('serverReload')
43 def do_reload(self, p: Params):
44 """Reload the server without reconfiguring."""
46 control.reload_all()
48 @gws.ext.command.cli('serverReconfigure')
49 def do_reconfigure(self, p: Params):
50 """Reconfigure and reload the server."""
52 control.reconfigure(p.manifest, p.config)
54 @gws.ext.command.cli('serverConfigure')
55 def do_configure(self, p: Params):
56 """Configure the server without reloading."""
58 control.configure_and_store(p.manifest, p.config)
60 @gws.ext.command.cli('serverConfigtest')
61 def do_configtest(self, p: ConfigTestParams):
62 """Test the configuration and report errors, optionally watching for changes."""
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 )