-
Notifications
You must be signed in to change notification settings - Fork 2
/
dev.sh
executable file
·72 lines (56 loc) · 2.14 KB
/
dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
############################## DEV_SCRIPT_MARKER ##############################
# This script is used to document and run recurring tasks in development. #
# #
# You can run your tasks using the script `./dev some-task`. #
# You can install the Sandstorm Dev Script Runner and run your tasks from any #
# nested folder using `dev some-task`. #
# https://github.com/sandstorm/Sandstorm.DevScriptRunner #
###############################################################################
set -e
######### TASKS #########
function build() {
go build -o ./bin/prunner ./cmd/prunner
_log_success "Built ./bin/prunner"
}
function memory-leak-start() {
build
_log_success "Starting prunner on http://127.0.0.1:9009 with profiling enabled:"
_log_success " http://127.0.0.1:9009/debug/pprof/"
./bin/prunner --path test/memory_leak_debugging --verbose --enable-profiling
}
function start-pipeline {
export PIPELINE_NAME=$1
if [ "$PIPELINE_NAME" == "" ]; then
_log_error "PIPELINE_NAME must be set in call to start-pipeline"
exit 1
fi
_log_warning "Generating auth token"
TOKEN=$(MINIMAL_OUTPUT=1 go run ./cmd/prunner debug)
_log_warning "Starting pipeline $PIPELINE_NAME"
curl -XPOST -H "Authorization: $TOKEN" -H "Content-type: application/json" -d "{
\"pipeline\": \"$PIPELINE_NAME\"
}" 'http://127.0.0.1:9009/pipelines/schedule'
curl -XGET -H "Authorization: $TOKEN" -H "Content-type: application/json" \
'http://127.0.0.1:9009/pipelines/jobs' | jq .
}
function analyze-heapdump {
DUMPNAME=heapdump-$(date +%s)
curl -o $DUMPNAME http://localhost:9009/debug/pprof/heap?gc=1
#curl -o $DUMPNAME http://localhost:9009/debug/pprof/allocs
PORT=$(jot -r 1 2000 65000)
go tool pprof -http=:$PORT $DUMPNAME
}
####### Utilities #######
_log_success() {
printf "\033[0;32m%s\033[0m\n" "${1}"
}
_log_warning() {
printf "\033[1;33m%s\033[0m\n" "${1}"
}
_log_error() {
printf "\033[0;31m%s\033[0m\n" "${1}"
}
# THIS NEEDS TO BE LAST!!!
# this will run your tasks
"$@"