From a05ba8982b6bd6ee564874a5a10f1169d156bbc0 Mon Sep 17 00:00:00 2001 From: gop Date: Thu, 9 Feb 2023 09:14:22 -0600 Subject: [PATCH] Makefile: Added background running and stop commands --- Makefile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b56c8ba..dd8f612 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,29 @@ GO ?= latest GORUN = env GO111MODULE=on go run quai-cpu-miner: - go build -o ./build/bin/quai-cpu-miner main.go + go build -o ./build/bin/quai-cpu-miner main.go @echo "Done building." - @echo "Run \"$(GOBIN)\" to launch quai-cpu-miner" + @echo "Run \"$(GOBIN)\" to launch quai-cpu-miner" # to manually select a location to mine run-mine: ./build/bin/quai-cpu-miner $(region) $(zone) +# to run in the background (manually set location) +run-mine-background: +ifeq (,$(wildcard logs)) + mkdir logs +endif + @nohup ./build/bin/quai-cpu-miner $(region) $(zone) 1 >> logs/slice-$(region)-$(zone).log 2>&1 & + +stop: +ifeq ($(shell uname -s),Darwin) + @if pgrep quai-cpu-miner; then pkill -f ./build/bin/quai-cpu-miner; fi + @while pgrep quai-cpu-miner >/dev/null; do \ + echo "Stopping all Quai Network CPU Miners, please wait until terminated."; \ + sleep 3; \ + done; +else + @echo "Stopping all Quai Network CPU Miners, please wait until terminated."; + @if pgrep quai-cpu-miner; then killall -w ./build/bin/quai-cpu-miner; fi +endif