diff options
-rw-r--r-- | ick2/workerapi.py | 36 | ||||
-rwxr-xr-x[-rw-r--r--] | start_ick | 12 |
2 files changed, 46 insertions, 2 deletions
diff --git a/ick2/workerapi.py b/ick2/workerapi.py index 5a7e835..bed14b4 100644 --- a/ick2/workerapi.py +++ b/ick2/workerapi.py @@ -21,5 +21,41 @@ class WorkerAPI(ick2.ResourceApiBase): # pragma: no cover def __init__(self, state): super().__init__('workers', state) + def get_routes(self, path): + return [ + { + 'method': 'POST', + 'path': path, + 'callback': self.POST(self.create), + }, + { + 'method': 'GET', + 'path': path, + 'callback': self.GET(self.list), + }, + { + 'method': 'GET', + 'path': '{}/<name>'.format(path), + 'callback': self.GET(self.show), + }, + { + 'method': 'DELETE', + 'path': '{}/<name>'.format(path), + 'callback': self.DELETE(self.delete), + }, + ] + def get_resource_name(self, resource): return resource['worker'] + + def create(self, body, **kwargs): + ick2.log.log( + 'trace', msg_text='create worker', body=body, kwargs=kwargs) + resource = self.mangle_new_resource(body) + name = self.get_resource_name(resource) + try: + self._state.get_resource(self._type_name, name) + except ick2.NotFound: + return self._state.add_resource(self._type_name, name, resource) + else: + raise ick2.ExistsAlready(name) diff --git a/start_ick b/start_ick index 96f745c..8c9d50f 100644..100755 --- a/start_ick +++ b/start_ick @@ -16,9 +16,17 @@ set -eux -export ICK_CONTROLLER_CONFIG=/etc/ick/controller.yaml +if [ "$#" = 1 ] +then + export ICK_CONTROLLER_CONFIG="$1" + export GUNICORN_LOG=gunicorn3.log +else + export ICK_CONTROLLER_CONFIG=/etc/ick/controller.yaml + export GUNICORN_LOG=/var/log/ick/gunicorn3.log +fi + gunicorn3 \ --bind 127.0.0.1:12765 \ - --log-file /var/log/ick/gunicorn3.log \ + --log-file "$GUNICORN_LOG" \ --log-level debug \ ick_controller:app |