Commit da0a323e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c86f2da3
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2020 Nexedi SA and Contributors. # Copyright (C) 2020-2021 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com> # Kirill Smelkov <kirr@nexedi.com>
# #
# This program is free software: you can Use, Study, Modify and Redistribute # This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your # it under the terms of the GNU General Public License version 3, or (at your
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
Usage: runneo.py <workdir> <cluster-name> [k1=v1] [k2=v2] ... Usage: runneo.py <workdir> <cluster-name> [k1=v1] [k2=v2] ...
{k->v} dict is optional arguments for NEOCluster.
<workdir>/ready is created with address of master after spawned cluster becomes <workdir>/ready is created with address of master after spawned cluster becomes
operational. operational.
""" """
...@@ -55,6 +57,7 @@ def main(): ...@@ -55,6 +57,7 @@ def main():
raise SystemExit(sinfo("terminated")) raise SystemExit(sinfo("terminated"))
signal(SIGTERM, _) signal(SIGTERM, _)
# SSL setup
flags = ' !ssl' flags = ' !ssl'
ca = kw.pop('ca', None) ca = kw.pop('ca', None)
cert = kw.pop('cert', None) cert = kw.pop('cert', None)
...@@ -66,6 +69,7 @@ def main(): ...@@ -66,6 +69,7 @@ def main():
flags = ' ssl' flags = ' ssl'
NEOCluster.SSL = (ca, cert, key) NEOCluster.SSL = (ca, cert, key)
# Start the cluster
cluster = NEOCluster([clusterName], adapter='SQLite', name=clusterName, temp_dir=workdir, **kw) cluster = NEOCluster([clusterName], adapter='SQLite', name=clusterName, temp_dir=workdir, **kw)
cluster.start() cluster.start()
defer(cluster.stop) defer(cluster.stop)
...@@ -73,7 +77,7 @@ def main(): ...@@ -73,7 +77,7 @@ def main():
cluster.expectClusterRunning() cluster.expectClusterRunning()
info("started master(s): %s" % (cluster.master_nodes,)) info("started master(s): %s" % (cluster.master_nodes,))
# dump information about ready cluster into readyfile # dump information about ready cluster into readyf
with open("%s.tmp" % readyf, "w") as f: with open("%s.tmp" % readyf, "w") as f:
f.write(cluster.master_nodes) # XXX ' ' separated if multiple masters f.write(cluster.master_nodes) # XXX ' ' separated if multiple masters
os.rename("%s.tmp" % readyf, readyf) # atomic os.rename("%s.tmp" % readyf, readyf) # atomic
...@@ -82,6 +86,7 @@ def main(): ...@@ -82,6 +86,7 @@ def main():
os.unlink(readyf) os.unlink(readyf)
defer(_) defer(_)
# started ok -> serve
while 1: while 1:
sleep(1) sleep(1)
......
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