diff --git a/src/comm/comm_client.cpp b/src/comm/comm_client.cpp index 0638c669..d428671c 100644 --- a/src/comm/comm_client.cpp +++ b/src/comm/comm_client.cpp @@ -45,9 +45,10 @@ namespace comm close(write_pipe[0]); close(read_pipe[1]); - // Wait for some time and check if websocat is still running properly. - util::sleep(20); - if (kill(pid, 0) == -1) + // Wait for some time and check if websocat process has closed the pipe. + util::sleep(300); + pollfd fds[1] = {{read_fd}}; + if (poll(fds, 1, 0) == -1 || (fds[0].revents & POLLHUP)) { close(read_fd); close(write_fd); diff --git a/src/comm/comm_server.cpp b/src/comm/comm_server.cpp index af43a337..6f07c49d 100644 --- a/src/comm/comm_server.cpp +++ b/src/comm/comm_server.cpp @@ -247,7 +247,7 @@ namespace comm comm::comm_client client; if (client.start(host, port, metric_thresholds, conf::cfg.peermaxsize) == -1) { - LOG_ERR << "Outbound connection attempt failed"; + LOG_ERR << "Outbound connection attempt failed: " << host << ":" << std::to_string(port); } else { diff --git a/src/util.cpp b/src/util.cpp index c08ebd7b..88739b2b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -204,6 +204,7 @@ namespace util sigset_t mask; sigemptyset(&mask); sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGPIPE); pthread_sigmask(SIG_BLOCK, &mask, NULL); } diff --git a/test/vm-cluster/cluster.sh b/test/vm-cluster/cluster.sh index bd5fc34b..1923de7d 100755 --- a/test/vm-cluster/cluster.sh +++ b/test/vm-cluster/cluster.sh @@ -140,12 +140,26 @@ fi # Run binary file setup for entire cluster. if [ $mode = "new" ] || [ $mode = "update" ]; then + + # Copy required files to hpfiles dir. + mkdir -p hpfiles/{bin,nodejs_contract} + strip $hpcore/build/hpcore + cp $hpcore/build/hpcore hpfiles/bin/ + cp $hpcore/examples/nodejs_contract/{package.json,echo_contract.js,hp-contract-lib.js} hpfiles/nodejs_contract/ + if [ $mode = "new" ]; then + cp ../bin/{libfuse3.so.3,libb2.so.1,fusermount3,websocketd,websocat,hpfs} hpfiles/bin/ + cp ./setup-hp.sh hpfiles/ + fi + for (( i=0; i<$vmcount; i++ )) do vmaddr=${vmaddrs[i]} let n=$i+1 /bin/bash ./setup-vm.sh $mode $n $vmpass $vmaddr $hpcore & done + + wait + rm -r hpfiles fi wait diff --git a/test/vm-cluster/setup-vm.sh b/test/vm-cluster/setup-vm.sh index 606e3e3e..76348b98 100755 --- a/test/vm-cluster/setup-vm.sh +++ b/test/vm-cluster/setup-vm.sh @@ -8,17 +8,6 @@ hpcore=$5 echo $nodeid. $vmaddr -# Copy required files to hpfiles dir. -mkdir -p hpfiles/{bin,nodejs_contract} - -strip $hpcore/build/hpcore -cp $hpcore/build/hpcore hpfiles/bin/ -cp $hpcore/examples/nodejs_contract/{package.json,echo_contract.js,hp-contract-lib.js} hpfiles/nodejs_contract/ -if [ $mode = "new" ]; then - cp ../bin/{libfuse3.so.3,libb2.so.1,fusermount3,websocketd,websocat,hpfs} hpfiles/bin/ - cp ./setup-hp.sh hpfiles/ -fi - echo "Uploading hp files..." sshpass -f vmpass.txt scp -rp hpfiles geveo@$vmaddr:~/ echo "Upload finished." @@ -29,6 +18,4 @@ if [ $mode = "new" ]; then sshpass -f vmpass.txt ssh geveo@$vmaddr 'echo sudo ~/hpfiles/bin/hpcore run ~/contract > ~/run.sh && sudo chmod +x ~/run.sh' mkdir ./cfg > /dev/null 2>&1 sshpass -f vmpass.txt scp geveo@$vmaddr:~/contract/cfg/hp.cfg ./cfg/node$nodeid.json -fi - -rm -r hpfiles \ No newline at end of file +fi \ No newline at end of file