for now, delegate will miss blocks after long time running.
BM suggest to restart client every day.
here is a method for automatic restart.
1. run wallet with this expect script, you should change "wallet_name" and "command line"
this script will start client automatic while it's quit.
#!/usr/bin/expect -f
set timeout -1
set default_port 1776
set port $default_port
### change wallet_name here
set wallet_name "delegate"
send_user "wallet name is: $wallet_name\n"
send_user "wallet passphrase: "
stty -echo
expect_user -re "(.*)\n"
stty echo
set wallet_pass $expect_out(1,string)
proc run_wallet {} {
global wallet_name wallet_pass default_port port
### change command line here
spawn ./bitshares_client --data-dir=delegate --p2p-port $port --server --httpport 9989 --rpcuser user --rpcpassword pass
expect -exact "(wallet closed) >>> "
send -- "about\r"
expect -exact "(wallet closed) >>> "
send -- "wallet_open $wallet_name\r"
expect -exact "$wallet_name (locked) >>> "
send -- "wallet_unlock 99999999\r"
expect -exact "passphrase: "
send -- "$wallet_pass\r"
expect -exact "$wallet_name (unlocked) >>> "
send -- "wallet_delegate_set_block_production ALL true\r"
expect -exact "$wallet_name (unlocked) >>> "
send -- "info\r"
expect -exact "$wallet_name (unlocked) >>> "
send -- "wallet_list_my_accounts\r"
interact
wait
if { $port == $default_port } {
set port [expr $port+1]
} else {
set port [expr $port-1]
}
}
while true {
run_wallet
}
2. kill the client every 24 hours.
call restart.py every 24 hours at crontab, this script will check next block generation timestamp, make sure there is enough time to restart client
#!/usr/bin/python
import requests
import json
import time
import os
safetime = 120 # safe time, 120 seconds is safe to restart client
auth = ('user', 'pass') ## user/pass for rpc service
url = "http://localhost:9989/rpc" ## rpc url
def main() :
headers = {'content-type': 'application/json'}
info = {
"method": "get_info",
"params": [],
"jsonrpc": "2.0",
"id": 1
}
while True:
info_res = requests.post(url, data=json.dumps(info), headers=headers, auth=auth)
info_json = json.loads(vars(info_res)["_content"])
if not "result" in info_json:
return
block_production_timestamp = info_json["result"]["wallet_next_block_production_timestamp"]
safe_timestamp = time.strftime("%Y%m%dT%H%M%S", time.localtime(time.time()+safetime))
if block_production_timestamp > safe_timestamp :
break;
#print("wait...")
time.sleep(10)
#print("kill...")
time.sleep(10) ## wait 10 second make sure it's broadcast out
os.system("killall -9 bitshares_client");
if __name__ == "__main__":
main()
3. we'll provide more suitable tools to detect the missing block and restart automatic soon.