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()
|
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:
|
if namespace == None:
|
||||||
import socket
|
import socket
|
||||||
@ -29,7 +29,7 @@ def load(check_strs, namespace=default_namespace, rundir='/run'):
|
|||||||
checks.append(module)
|
checks.append(module)
|
||||||
|
|
||||||
for check in checks:
|
for check in checks:
|
||||||
r = check.health()
|
r = check.health(args, kwargs)
|
||||||
if r == False:
|
if r == False:
|
||||||
raise RuntimeError('liveness check {} failed'.format(str(check)))
|
raise RuntimeError('liveness check {} failed'.format(str(check)))
|
||||||
logg.info('liveness check passed: {}'.format(str(check)))
|
logg.info('liveness check passed: {}'.format(str(check)))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='liveness',
|
name='liveness',
|
||||||
version='0.0.1a4',
|
version='0.0.1a5',
|
||||||
packages=['liveness'],
|
packages=['liveness'],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
)
|
)
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
def health():
|
def health(*args, **kwargs):
|
||||||
return False
|
return False
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
def health():
|
def health(*args, **kwargs):
|
||||||
return True
|
return True
|
||||||
|
@ -114,5 +114,14 @@ class TestImports(unittest.TestCase):
|
|||||||
os.stat(error_path)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user