Commit 979eff4f authored by Xavier Thompson's avatar Xavier Thompson

stack/monitor: Add promise runner script

This script reuses the promise launcher from slapos.core to launch the
instance promises using the python executable installed by the SR.
parent f76bac48
......@@ -41,6 +41,68 @@ eggs =
Jinja2
depends =
${slapos-toolbox:recipe}
promises-need-this-script-in-path =
${runpromise:recipe}
[runpromise]
recipe = zc.recipe.egg
eggs =
slapos.core
scripts = ${:_buildout_section_name_}
entry-points =
${:scripts}=never_used:never_called
initialization =
import argparse
from slapos.grid.promise import PromiseLauncher
from slapos.cli.entry import SlapOSApp
parser = argparse.ArgumentParser()
parser.add_argument('--promise-folder', required=True)
parser.add_argument('--legacy-promise-folder', required=True)
parser.add_argument('--promise-timeout', type=int, required=True)
parser.add_argument('--uid', type=int, required=True)
parser.add_argument('--gid', type=int, required=True)
parser.add_argument('--partition-folder', required=True)
parser.add_argument('--log-folder', required=True)
parser.add_argument('--force', type=int, required=True)
parser.add_argument('--check-anomaly', type=int, required=True)
parser.add_argument('--master-url', required=True)
parser.add_argument('--partition-cert', required=True)
parser.add_argument('--partition-key', required=True)
parser.add_argument('--partition-id', required=True)
parser.add_argument('--computer-id', required=True)
args = parser.parse_args()
promise_config = {
'promise-folder': args.promise_folder,
'legacy-promise-folder': args.legacy_promise_folder,
'promise-timeout': args.promise_timeout,
'uid': args.uid,
'gid': args.gid,
'partition-folder': args.partition_folder,
'log-folder': args.log_folder,
'force': bool(args.force),
'check-anomaly': bool(args.check_anomaly),
'master-url': args.master_url,
'partition-cert': args.partition_cert,
'partition-key': args.partition_key,
'partition-id': args.partition_id,
'computer-id': args.computer_id,
}
# Get the same logger as a standard slapos command
app = SlapOSApp()
app.options, _ = app.parser.parse_known_args([])
app.configure_logging()
logger = app.log
try:
promise_checker = PromiseLauncher(config=promise_config, logger=logger)
promise_checker.run()
except Exception:
sys.exit(1)
sys.exit(0)
# Monitor templates files
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment