I'm facing some issues with the Tezos Node CPR script from Etom Knudsen, which serves to automatically restart the node after failure. The script has a bug in the function to call network stats in line 35, which I solved using the solution suggested by a user on GitHub.
The script calls the network statistics from the node to check if it is connected to other peers:
curl -s 127.0.0.1:8732/network/stat/
If it is not, the call will return something like:
It also checks when the node received the last block from the network, by calling:
curl -s 127.0.0.1:8732/chains/main/blocks/head/header/
I suspect that the latter has never worked, as during network failures the rpc call seems to return an empty line, preventing the script to determine when the last block arrived. By default the script is configured to restart the node after 180s when no block arrived during this time. However, it fails to do so, as indicated, for instance, by the following line:
2019-03-23T06:55:56Z Waiting. Last block was 515 secs ago
I believe since the most recent node update (commit hash: 366f64f3...) also the network stat function fails, as the node seems to receive and send some data also when it is not connected to any other peer. This is indicated by the following:
2019-03-23T06:55:35Z Waiting. Last block was 494 secs ago) 2019-03-23T06:55:40Z Found p2p activity 2019-03-23T06:55:40Z Looking for p2p avtivity - will wait for max 90 secs 2019-03-23T06:55:40Z Waiting. Last block was 499 secs ago) 2019-03-23T06:55:45Z Found p2p activity 2019-03-23T06:55:45Z Looking for p2p avtivity - will wait for max 90 secs 2019-03-23T06:55:45Z Waiting. Last block was 504 secs ago) 2019-03-23T06:55:51Z Found p2p activity
Both issues result in the script not working as intended and the node does not automatically restart any longer.
Has anyone also observed these issues and revised the script accordingly? Or does anyone know another restart script for the Tezos node that works better?