Coverage for gws-app/gws/server/core.py: 100%

81 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-16 22:59 +0200

1"""Configuration for embedded servers.""" 

2 

3from typing import Optional, Literal 

4 

5import gws 

6 

7 

8class SpoolConfig(gws.Config): 

9 """Spool server module""" 

10 

11 enabled: Optional[bool] 

12 """The module is enabled. (deprecated in 8.2)""" 

13 workers: int = 4 

14 """Number of processes for this module.""" 

15 jobFrequency: gws.Duration = '3' 

16 """Background jobs checking frequency.""" 

17 timeout: gws.Duration = '300' 

18 """Job timeout.""" 

19 

20 

21class WebConfig(gws.Config): 

22 """Web server module""" 

23 

24 enabled: Optional[bool] 

25 """The module is enabled. (deprecated in 8.2)""" 

26 workers: int = 4 

27 """Number of processes for this module.""" 

28 maxRequestLength: int = 10 

29 """Max request length in megabytes.""" 

30 timeout: gws.Duration = '60' 

31 """Web server timeout.""" 

32 

33 

34class MapproxyConfig(gws.Config): 

35 """Mapproxy server module""" 

36 

37 enabled: Optional[bool] 

38 """The module is enabled. (deprecated in 8.2)""" 

39 workers: int = 4 

40 """Number of processes for this module.""" 

41 host: str = 'localhost' 

42 """Host to run the module on.""" 

43 port: int = 5000 

44 """Port number.""" 

45 forceStart: bool = False 

46 """Start even if no configuration is defined.""" 

47 

48 

49class MonitorConfig(gws.Config): 

50 """Monitor module configuration.""" 

51 

52 enabled: Optional[bool] 

53 """The module is enabled. (deprecated in 8.2)""" 

54 frequency: gws.Duration = '30' 

55 """Periodic tasks frequency.""" 

56 disableWatch: bool = False 

57 """Disable file system watching. (added in 8.2)""" 

58 ignore: Optional[list[gws.Regex]] 

59 """Ignore paths that match these regexes. (deprecated in 8.2)""" 

60 

61 

62class QgisConfig(gws.Config): 

63 """External QGIS server configuration.""" 

64 

65 host: str = 'qgis' 

66 """Host where the qgis server runs.""" 

67 port: int = 80 

68 """Port number.""" 

69 

70 

71class LogConfig(gws.Config): 

72 """Logging configuration""" 

73 

74 path: str = '' 

75 """Log path.""" 

76 level: str = 'INFO' 

77 """Logging level.""" 

78 

79 

80class Config(gws.Config): 

81 """Server module configuration""" 

82 

83 mapproxy: Optional[MapproxyConfig] 

84 """Bundled Mapproxy module.""" 

85 monitor: Optional[MonitorConfig] 

86 """Monitor configuration.""" 

87 log: Optional[LogConfig] 

88 """Logging configuration.""" 

89 qgis: Optional[QgisConfig] 

90 """Qgis server configuration.""" 

91 spool: Optional[SpoolConfig] 

92 """Spool server module.""" 

93 web: Optional[WebConfig] 

94 """Web server module.""" 

95 

96 withWeb: bool = True 

97 """Enable the web server. (added in 8.2)""" 

98 withSpool: bool = True 

99 """Enable the spool server. (added in 8.2)""" 

100 withMapproxy: bool = True 

101 """Enable the mapproxy server. (added in 8.2)""" 

102 withMonitor: bool = True 

103 """Enable the monitor. (added in 8.2)""" 

104 

105 templates: Optional[list[gws.ext.config.template]] 

106 """Configuration templates.""" 

107 

108 autoRun: str = '' 

109 """Shell command to run before the server start. (deprecated in 8.2)""" 

110 preConfigure: str = '' 

111 """Shell or python script to run before configuring the server. (added in 8.2)""" 

112 postConfigure: str = '' 

113 """Shell or python script to run run after the service has been configured. (added in 8.2)""" 

114 timeZone: str = 'Europe/Berlin' 

115 """Timezone for this server."""