mirror of
https://github.com/basicswap/basicswap.git
synced 2025-03-12 09:38:03 +00:00
up
This commit is contained in:
parent
2a183a1ef3
commit
2f03aca158
3 changed files with 74 additions and 4 deletions
|
@ -13,6 +13,7 @@ import time
|
|||
import base64
|
||||
import random
|
||||
import shutil
|
||||
import signal
|
||||
import string
|
||||
import struct
|
||||
import secrets
|
||||
|
@ -918,6 +919,15 @@ class BasicSwap(BaseApp):
|
|||
def stopDaemon(self, coin) -> None:
|
||||
if coin in (Coins.XMR, Coins.DCR, Coins.WOW):
|
||||
return
|
||||
if coin == Coins.XNO:
|
||||
raise NotImplementedError("stop nano_node daemon")
|
||||
# there is no nano-cli. simply kill the process
|
||||
# TODO get pid of daemon
|
||||
pid = -1
|
||||
# TODO verify that the process actually is nano_node
|
||||
# or if nano_node is no longer running
|
||||
# and the pid is now used by a different process
|
||||
os.kill(pid, signal.SIGKILL)
|
||||
num_tries = 10
|
||||
authcookiepath = os.path.join(self.getChainDatadirPath(coin), '.cookie')
|
||||
stopping = False
|
||||
|
|
64
prepare.sh
64
prepare.sh
|
@ -8,6 +8,12 @@ basicswap_dir="$HOME/.basicswap"
|
|||
|
||||
particld_pid_file="$basicswap_dir/particl/particl.pid"
|
||||
|
||||
nano_node_pid_file="$basicswap_dir/nano/nano_node.pid"
|
||||
|
||||
|
||||
|
||||
# start particl daemon
|
||||
|
||||
if [ -e "$particld_pid_file" ]; then
|
||||
:
|
||||
# TODO check if particl daemon is running
|
||||
|
@ -31,6 +37,46 @@ if ! [ -e "$particld_pid_file" ]; then
|
|||
echo "to stop the particl daemon: kill \$(cat ${particld_pid_file@Q})"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# start nano_node daemon
|
||||
|
||||
if [ -e "$nano_node_pid_file" ]; then
|
||||
nano_node_pid=$(< "$nano_node_pid_file")
|
||||
if [ -z "$nano_node_pid" ]; then
|
||||
echo "deleting empty pidfile $nano_node_pid_file"
|
||||
rm "$nano_node_pid_file"
|
||||
fi
|
||||
# TODO check if nano_node daemon is running
|
||||
# otherwise delete $nano_node_pid_file
|
||||
fi
|
||||
|
||||
if ! [ -e "$nano_node_pid_file" ]; then
|
||||
echo "starting nano_node daemon ..."
|
||||
# see also bin/basicswap_prepare.py
|
||||
args=(
|
||||
"$DEFAULT_TEST_BINDIR/nano/nano_node"
|
||||
--daemon
|
||||
--data_path "$basicswap_dir/nano"
|
||||
--config rpc.enable=true
|
||||
--rpcconfig enable_control=true
|
||||
--config logging.log_rpc=false
|
||||
)
|
||||
logfile="$basicswap_dir/nano/log/log_$(date --utc +%F_%H-%M-%S_%N).log"
|
||||
printf ">"; printf " %q" "${args[@]}"; printf " &> %s\n" "$logfile"
|
||||
"${args[@]}" &> "$logfile" &
|
||||
nano_node_pid=$!
|
||||
echo $nano_node_pid > "$nano_node_pid_file"
|
||||
echo "starting nano_node daemon done. pid $nano_node_pid"
|
||||
echo "to stop the nano_node daemon: kill \$(cat ${nano_node_pid_file@Q}); rm ${nano_node_pid_file@Q}"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# move old config files
|
||||
# otherwise bin/basicswap_prepare.py fails
|
||||
|
||||
move_paths=(
|
||||
"$basicswap_dir/basicswap.json"
|
||||
"$basicswap_dir/particl/particl.conf"
|
||||
|
@ -45,6 +91,10 @@ for path in "${move_paths[@]}"; do
|
|||
mv -v "$path" "$path.bak.$t"
|
||||
done
|
||||
|
||||
|
||||
|
||||
# run bin/basicswap_prepare.py
|
||||
|
||||
withcoin=monero,nano
|
||||
withcoin=nano
|
||||
|
||||
|
@ -54,8 +104,14 @@ withoutcoin=
|
|||
# no. particl is required
|
||||
#withoutcoin=particl # debug: start faster
|
||||
|
||||
dont_manage_daemons=particl
|
||||
dont_manage_daemons=particl,nano
|
||||
|
||||
./python.sh bin/basicswap_prepare.py --withcoin=$withcoin --withoutcoin=$withoutcoin --dont_manage_daemons=$dont_manage_daemons
|
||||
#./python.sh bin/basicswap_prepare.py --withcoin=$withcoin --withoutcoin=$withoutcoin --initwalletsonly
|
||||
#./python.sh bin/basicswap_prepare.py --withcoin=$withcoin --withoutcoin=$withoutcoin --preparebinonly
|
||||
args=(
|
||||
./python.sh
|
||||
bin/basicswap_prepare.py
|
||||
--withcoin=$withcoin
|
||||
--withoutcoin=$withoutcoin
|
||||
--dont_manage_daemons=$dont_manage_daemons
|
||||
)
|
||||
printf ">"; printf " %q" "${args[@]}"; printf "\n"
|
||||
"${args[@]}"
|
||||
|
|
4
stop-nano_node.sh
Executable file
4
stop-nano_node.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
kill $(cat "$HOME/.basicswap/nano/nano_node.pid")
|
||||
rm "$HOME/.basicswap/nano/nano_node.pid"
|
Loading…
Reference in a new issue