catch etcd in scripts/
This commit is contained in:
parent
d9dd6b48dc
commit
82a69701ce
1 changed files with 6 additions and 4 deletions
|
@ -71,20 +71,22 @@ if __name__ == '__main__':
|
||||||
# module to not inherit anything from parent.
|
# module to not inherit anything from parent.
|
||||||
# mp.set_start_method('spawn')
|
# mp.set_start_method('spawn')
|
||||||
arguments = vars(args)
|
arguments = vars(args)
|
||||||
print(arguments)
|
|
||||||
print(etcd_parser)
|
|
||||||
|
|
||||||
name = arguments.pop('command')
|
name = arguments.pop('command')
|
||||||
mod = importlib.import_module('uncloud.{}.main'.format(name))
|
mod = importlib.import_module('uncloud.{}.main'.format(name))
|
||||||
main = getattr(mod, 'main')
|
main = getattr(mod, 'main')
|
||||||
|
|
||||||
if component in ETCD_COMPONENTS:
|
# If the component requires etcd3, we import it and catch the
|
||||||
|
# etcd3.exceptions.ConnectionFailedError
|
||||||
|
if name in ETCD_COMPONENTS:
|
||||||
import etcd3
|
import etcd3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
main(arguments)
|
main(arguments)
|
||||||
except UncloudException as err:
|
except UncloudException as err:
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
except etcd3.exceptions.ConnectionFailedError as err:
|
||||||
|
logger.error("Cannot connect to etcd")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.exception(err)
|
logger.exception(err)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue