Add opt args to health function
This commit is contained in:
parent
a0153bfa19
commit
f785527156
@ -14,7 +14,7 @@ if default_namespace == None:
|
||||
default_namespace = socket.gethostname()
|
||||
|
||||
|
||||
def load(check_strs, namespace=default_namespace, rundir='/run'):
|
||||
def load(check_strs, namespace=default_namespace, rundir='/run', *args, **kwargs):
|
||||
|
||||
if namespace == None:
|
||||
import socket
|
||||
@ -29,7 +29,7 @@ def load(check_strs, namespace=default_namespace, rundir='/run'):
|
||||
checks.append(module)
|
||||
|
||||
for check in checks:
|
||||
r = check.health()
|
||||
r = check.health(args, kwargs)
|
||||
if r == False:
|
||||
raise RuntimeError('liveness check {} failed'.format(str(check)))
|
||||
logg.info('liveness check passed: {}'.format(str(check)))
|
||||
|
@ -1,7 +1,7 @@
|
||||
from setuptools import setup
|
||||
setup(
|
||||
name='liveness',
|
||||
version='0.0.1a4',
|
||||
version='0.0.1a5',
|
||||
packages=['liveness'],
|
||||
include_package_data=True,
|
||||
)
|
||||
|
@ -1,2 +1,2 @@
|
||||
def health():
|
||||
def health(*args, **kwargs):
|
||||
return False
|
||||
|
@ -1,2 +1,2 @@
|
||||
def health():
|
||||
def health(*args, **kwargs):
|
||||
return True
|
||||
|
@ -114,5 +114,14 @@ class TestImports(unittest.TestCase):
|
||||
os.stat(error_path)
|
||||
|
||||
|
||||
def test_args(self):
|
||||
checks = ['tests.imports.import_args']
|
||||
liveness.linux.load(checks, namespace=self.unit, rundir=self.run_dir, args=['foo'], kwargs={'bar': 42})
|
||||
f = open(self.pid_path, 'r')
|
||||
r = f.read()
|
||||
f.close()
|
||||
self.assertEqual(str(os.getpid()), r)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user