new: [internal] Add /healthcheck endpoint

pull/648/head
Jakub Onderka 2024-01-06 13:07:10 +01:00
parent 57e04d6b6c
commit c65c65621f
1 changed files with 16 additions and 7 deletions

View File

@ -161,6 +161,11 @@ def load_package_modules():
return mhandlers, modules return mhandlers, modules
class Healthcheck(tornado.web.RequestHandler):
def get(self):
self.write(b'{"status": true}')
class ListModules(tornado.web.RequestHandler): class ListModules(tornado.web.RequestHandler):
global loaded_modules global loaded_modules
global mhandlers global mhandlers
@ -168,12 +173,12 @@ class ListModules(tornado.web.RequestHandler):
def get(self): def get(self):
ret = [] ret = []
for module in loaded_modules: for module in loaded_modules:
x = {} ret.append({
x['name'] = module 'name': module,
x['type'] = mhandlers['type:' + module] 'type': mhandlers['type:' + module],
x['mispattributes'] = mhandlers[module].introspection() 'mispattributes': mhandlers[module].introspection(),
x['meta'] = mhandlers[module].version() 'meta': mhandlers[module].version()
ret.append(x) })
log.debug('MISP ListModules request') log.debug('MISP ListModules request')
self.write(json.dumps(ret)) self.write(json.dumps(ret))
@ -268,7 +273,11 @@ def main():
mispmod = importlib.import_module(module) mispmod = importlib.import_module(module)
mispmod.register(mhandlers, loaded_modules) mispmod.register(mhandlers, loaded_modules)
service = [(r'/modules', ListModules), (r'/query', QueryModule)] service = [
(r'/modules', ListModules),
(r'/query', QueryModule),
(r'/healthcheck', Healthcheck),
]
application = tornado.web.Application(service) application = tornado.web.Application(service)
try: try: