Skip to content

Commit

Permalink
Merge pull request #2777 from phillxnet/2766-(t)-replication-spawn-error
Browse files Browse the repository at this point in the history
(t) replication spawn error #2766
  • Loading branch information
phillxnet authored Jan 15, 2024
2 parents b870fa2 + 795133c commit 08fbecc
Show file tree
Hide file tree
Showing 5 changed files with 578 additions and 526 deletions.
16 changes: 9 additions & 7 deletions src/rockstor/scripts/scheduled_tasks/send_replica.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2012-2020 RockStor, Inc. <http://rockstor.com>
Copyright (c) 2012-2023 RockStor, Inc. <https://rockstor.com>
This file is part of RockStor.
RockStor is free software; you can redistribute it and/or modify
Expand All @@ -13,7 +13,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""

import sys
Expand All @@ -28,25 +28,27 @@ def main():
rid = int(sys.argv[1])
ctx = zmq.Context()
poll = zmq.Poller()
num_tries = 12
num_tries = 3
while True:
req = ctx.socket(zmq.DEALER)
poll.register(req, zmq.POLLIN)
req.connect("ipc://%s" % settings.REPLICATION.get("ipc_socket"))
req.send_multipart(["new-send", b"%d" % rid])
ipc_socket = settings.REPLICATION.get("ipc_socket")
req.connect(f"ipc://{ipc_socket}")
req.send_multipart([b"new-send", f"{rid}".encode("utf-8")])

socks = dict(poll.poll(5000))
if socks.get(req) == zmq.POLLIN:
rcommand, reply = req.recv_multipart()
if rcommand == "SUCCESS":
print(f"rcommand={rcommand}, reply={reply}")
if rcommand == b"SUCCESS":
print(reply)
break
ctx.destroy(linger=0)
sys.exit(reply)
num_tries -= 1
print(
"No response from Replication service. Number of retry "
"attempts left: %d" % num_tries
f"attempts left: {num_tries}"
)
if num_tries == 0:
ctx.destroy(linger=0)
Expand Down
Loading

0 comments on commit 08fbecc

Please sign in to comment.