Skip to content

Commit 51c36c4

Browse files
committed
Replace rerun with watchdog
1 parent c747961 commit 51c36c4

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

Makefile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ kubectl:
3030
cluster-up:
3131
@$(MAKE) registry-all
3232
@$(MAKE) cli
33-
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
33+
@kill $(shell pgrep -f make) >/dev/null 2>&1 || true
3434
@./bin/cortex -c=./dev/config/cluster.yaml cluster up
3535
@$(MAKE) kubectl
3636

3737
cluster-up-y:
3838
@$(MAKE) registry-all
3939
@$(MAKE) cli
40-
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
40+
@kill $(shell pgrep -f make) >/dev/null 2>&1 || true
4141
@./bin/cortex -c=./dev/config/cluster.yaml cluster up --yes
4242
@$(MAKE) kubectl
4343

4444
cluster-down:
4545
@$(MAKE) manager-local
4646
@$(MAKE) cli
47-
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
47+
@kill $(shell pgrep -f make) >/dev/null 2>&1 || true
4848
@./bin/cortex -c=./dev/config/cluster.yaml cluster down
4949

5050
cluster-down-y:
5151
@$(MAKE) manager-local
5252
@$(MAKE) cli
53-
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
53+
@kill $(shell pgrep -f make) >/dev/null 2>&1 || true
5454
@./bin/cortex -c=./dev/config/cluster.yaml cluster down --yes
5555

5656
cluster-info:
@@ -61,13 +61,13 @@ cluster-info:
6161
cluster-configure:
6262
@$(MAKE) registry-all
6363
@$(MAKE) cli
64-
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
64+
@kill $(shell pgrep -f make) >/dev/null 2>&1 || true
6565
@./bin/cortex -c=./dev/config/cluster.yaml cluster configure
6666

6767
cluster-configure-y:
6868
@$(MAKE) registry-all
6969
@$(MAKE) cli
70-
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
70+
@kill $(shell pgrep -f make) >/dev/null 2>&1 || true
7171
@./bin/cortex -c=./dev/config/cluster.yaml cluster configure --yes
7272

7373
operator-stop:
@@ -123,18 +123,21 @@ manager-local:
123123
.PHONY: cli
124124
cli:
125125
@mkdir -p ./bin
126-
@GOARCH=amd64 CGO_ENABLED=0 go build -o ./bin/cortex ./cli
126+
@go build -o ./bin/cortex ./cli
127127

128128
cli-watch:
129-
@rerun -watch ./pkg ./cli -ignore ./vendor ./bin -run sh -c "go build -installsuffix cgo -o ./bin/cortex ./cli && echo 'CLI built.'"
129+
@clear && echo "building cli..."
130+
@$(MAKE) cli
131+
@clear && echo -e "\033[1;32mCLI built\033[0m"
132+
@watchmedo shell-command --command='clear && echo "rebuilding cli..." && go build -o ./bin/cortex ./cli && clear && echo "\033[1;32mCLI built\033[0m"' --patterns '*.go;*.yaml' --recursive --drop ./pkg ./cli
130133

131134
aws-clear-bucket:
132135
@./dev/aws.sh clear-bucket
133136

134137
tools:
135138
@go get -u -v golang.org/x/lint/golint
136-
@go get -u -v github.com/VojtechVitek/rerun/cmd/rerun
137-
@pip3 install black
139+
@python3 -m pip install black watchdog argh pyyaml
140+
@echo -e "\nyou may also wish to install libyaml (via \`brew install libyaml\` or \`sudo apt install libyaml-dev\`)"
138141

139142
format:
140143
@./dev/format.sh

dev/operator_local.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -euo pipefail
1919

2020
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"
2121

22-
kill $(pgrep -f rerun) >/dev/null 2>&1 || true
22+
kill $(pgrep -f make) >/dev/null 2>&1 || true
2323

2424
eval $(python3 $ROOT/manager/cluster_config_env.py "$ROOT/dev/config/cluster.yaml")
2525

@@ -34,7 +34,20 @@ fi
3434
export CORTEX_OPERATOR_IN_CLUSTER=false
3535
export CORTEX_CLUSTER_CONFIG_PATH=~/.cortex/cluster-dev.yaml
3636

37-
rerun -watch $ROOT/pkg $ROOT/cli $ROOT/dev/config -ignore $ROOT/vendor $ROOT/bin -run sh -c \
38-
"go build -o $ROOT/bin/operator $ROOT/pkg/operator && go build -installsuffix cgo -o $ROOT/bin/cortex $ROOT/cli && $ROOT/bin/operator"
37+
clear && echo "starting local operator..."
38+
39+
mkdir -p ./bin && go build -o $ROOT/bin/cortex $ROOT/cli && go build -o $ROOT/bin/operator $ROOT/pkg/operator && ($ROOT/bin/operator &)
40+
41+
trap ctrl_c INT
42+
function ctrl_c() {
43+
kill $(pgrep -f /bin/operator) >/dev/null 2>&1
44+
}
45+
46+
watchmedo shell-command \
47+
--command='kill $(pgrep -f /bin/operator);'" clear && echo 'restarting local operator...' && go build -o $ROOT/bin/cortex $ROOT/cli && go build -o $ROOT/bin/operator $ROOT/pkg/operator && $ROOT/bin/operator &" \
48+
--patterns '*.go;*.yaml' \
49+
--recursive \
50+
--drop \
51+
$ROOT/pkg $ROOT/cli $ROOT/dev/config
3952

4053
# go run -race $ROOT/pkg/operator/main.go # Check for race conditions. Doesn't seem to catch them all?

0 commit comments

Comments
 (0)