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

88 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-17 01:37 +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: bool = True 

12 """The module is enabled.""" 

13 threads: int = 0 

14 """Number of threads for this module. (deprecated in 8.0)""" 

15 workers: int = 4 

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

17 jobFrequency: gws.Duration = '3' 

18 """Background jobs checking frequency.""" 

19 timeout: gws.Duration = '300' 

20 """Job timeout. (added in 8.1)""" 

21 

22 

23class WebConfig(gws.Config): 

24 """Web server module""" 

25 

26 enabled: bool = True 

27 """The module is enabled.""" 

28 threads: int = 0 

29 """Number of threads for this module. (deprecated in 8.0)""" 

30 workers: int = 4 

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

32 maxRequestLength: int = 10 

33 """Max request length in megabytes.""" 

34 timeout: gws.Duration = '60' 

35 """Web server timeout. (added in 8.1)""" 

36 

37 

38class MapproxyConfig(gws.Config): 

39 """Mapproxy server module""" 

40 

41 enabled: bool = True 

42 """The module is enabled.""" 

43 threads: int = 0 

44 """Number of threads for this module. (deprecated in 8.0)""" 

45 workers: int = 4 

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

47 host: str = 'localhost' 

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

49 port: int = 5000 

50 """Port number.""" 

51 forceStart: bool = False 

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

53 

54 

55class MonitorConfig(gws.Config): 

56 enabled: bool = True 

57 """The module is enabled.""" 

58 frequency: gws.Duration = '30' 

59 """Filesystem changes check frequency.""" 

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

61 """Ignore paths that match these regexes.""" 

62 

63 

64class QgisConfig(gws.Config): 

65 """External QGIS server configuration.""" 

66 

67 host: str = 'qgis' 

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

69 port: int = 80 

70 """Port number.""" 

71 """max concurrent requests to this server""" 

72 

73 debug: int = 0 

74 """QGIS_DEBUG (env. variable) (deprecated in 8.0)""" 

75 serverLogLevel: int = 2 

76 """QGIS_SERVER_LOG_LEVEL (env. variable) (deprecated in 8.0)""" 

77 serverCacheSize: int = 10000000 

78 """QGIS_SERVER_CACHE_SIZE (env. variable) (deprecated in 8.0)""" 

79 maxCacheLayers: int = 4000 

80 """MAX_CACHE_LAYERS (env. variable) (deprecated in 8.0)""" 

81 searchPathsForSVG: Optional[list[gws.DirPath]] 

82 """searchPathsForSVG (ini setting) (deprecated in 8.0)""" 

83 legend: Optional[dict] 

84 """default legend settings (deprecated in 8.0)""" 

85 

86 

87class LogConfig(gws.Config): 

88 """Logging configuration""" 

89 

90 path: str = '' 

91 """Log path.""" 

92 level: Literal['ERROR', 'INFO', 'DEBUG'] = 'INFO' 

93 """Logging level.""" 

94 

95 

96class Config(gws.Config): 

97 """Server module configuration""" 

98 

99 mapproxy: Optional[MapproxyConfig] = {} 

100 """Bundled Mapproxy module.""" 

101 monitor: Optional[MonitorConfig] = {} 

102 """Monitor configuration.""" 

103 log: Optional[LogConfig] = {} 

104 """Logging configuration.""" 

105 qgis: Optional[QgisConfig] = {} 

106 """Qgis server configuration.""" 

107 spool: Optional[SpoolConfig] = {} 

108 """Spool server module.""" 

109 web: Optional[WebConfig] = {} 

110 """Web server module.""" 

111 

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

113 """Configuration templates.""" 

114 

115 autoRun: str = '' 

116 """Shell command to run before server start.""" 

117 timeout: gws.Duration = '60' 

118 """Server timeout. (deprecated in 8.1)""" 

119 timeZone: str = 'UTC' 

120 """Timezone for this server."""