1031 |
1035 |
1032 |
1036 |
1033 def wsgichoices(): |
1037 def wsgichoices(): |
1034 return tuple(WSGI_CHOICES) |
1038 return tuple(WSGI_CHOICES) |
1035 |
1039 |
1036 |
1040 if WSGI_CHOICES: |
1037 class WSGIStartHandler(InstanceCommand): |
1041 class WSGIStartHandler(InstanceCommand): |
1038 """Start an interactive wsgi server """ |
1042 """Start an interactive wsgi server """ |
1039 name = 'wsgi' |
1043 name = 'wsgi' |
1040 actionverb = 'started' |
1044 actionverb = 'started' |
1041 arguments = '<instance>' |
1045 arguments = '<instance>' |
1042 |
1046 |
1043 @property |
1047 @property |
1044 def options(self): |
1048 def options(self): |
1045 return ( |
1049 return ( |
1046 ("debug", |
1050 ("debug", |
1047 {'short': 'D', 'action': 'store_true', |
1051 {'short': 'D', 'action': 'store_true', |
1048 'default': False, |
1052 'default': False, |
1049 'help': 'start server in debug mode.'}), |
1053 'help': 'start server in debug mode.'}), |
1050 ('method', |
1054 ('method', |
1051 {'short': 'm', |
1055 {'short': 'm', |
1052 'type': 'choice', |
1056 'type': 'choice', |
1053 'metavar': '<method>', |
1057 'metavar': '<method>', |
1054 'default': 'stdlib', |
1058 'default': 'stdlib', |
1055 'choices': wsgichoices(), |
1059 'choices': wsgichoices(), |
1056 'help': 'wsgi utility/method'}), |
1060 'help': 'wsgi utility/method'}), |
1057 ('loglevel', |
1061 ('loglevel', |
1058 {'short': 'l', |
1062 {'short': 'l', |
1059 'type': 'choice', |
1063 'type': 'choice', |
1060 'metavar': '<log level>', |
1064 'metavar': '<log level>', |
1061 'default': None, |
1065 'default': None, |
1062 'choices': ('debug', 'info', 'warning', 'error'), |
1066 'choices': ('debug', 'info', 'warning', 'error'), |
1063 'help': 'debug if -D is set, error otherwise', |
1067 'help': 'debug if -D is set, error otherwise', |
1064 }), |
1068 }), |
1065 ) |
1069 ) |
1066 |
1070 |
1067 def wsgi_instance(self, appid): |
1071 def wsgi_instance(self, appid): |
1068 config = cwcfg.config_for(appid, debugmode=self['debug']) |
1072 config = cwcfg.config_for(appid, debugmode=self['debug']) |
1069 init_cmdline_log_threshold(config, self['loglevel']) |
1073 init_cmdline_log_threshold(config, self['loglevel']) |
1070 assert config.name == 'all-in-one' |
1074 assert config.name == 'all-in-one' |
1071 meth = self['method'] |
1075 meth = self['method'] |
1072 server = WSGI_CHOICES[meth] |
1076 server = WSGI_CHOICES[meth] |
1073 return server.run(config) |
1077 return server.run(config) |
1074 |
1078 |
|
1079 CWCTL.register(WSGIStartHandler) |
1075 |
1080 |
1076 |
1081 |
1077 for cmdcls in (ListCommand, |
1082 for cmdcls in (ListCommand, |
1078 CreateInstanceCommand, DeleteInstanceCommand, |
1083 CreateInstanceCommand, DeleteInstanceCommand, |
1079 StartInstanceCommand, StopInstanceCommand, RestartInstanceCommand, |
1084 StartInstanceCommand, StopInstanceCommand, RestartInstanceCommand, |
1080 WSGIStartHandler, |
|
1081 ReloadConfigurationCommand, StatusCommand, |
1085 ReloadConfigurationCommand, StatusCommand, |
1082 UpgradeInstanceCommand, |
1086 UpgradeInstanceCommand, |
1083 ListVersionsInstanceCommand, |
1087 ListVersionsInstanceCommand, |
1084 ShellCommand, |
1088 ShellCommand, |
1085 RecompileInstanceCatalogsCommand, |
1089 RecompileInstanceCatalogsCommand, |