-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.toml
81 lines (65 loc) · 2.08 KB
/
Makefile.toml
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
73
74
75
76
77
78
79
80
81
[tasks.format]
command = "cargo"
args = ["fmt", "--", "--emit=files"]
# Convenient tasks to provide "cargo make start X" sub-commands
[tasks.start]
script_runner = "@duckscript"
script = "cm_run_task start-${1}"
[tasks.stop]
script_runner = "@duckscript"
script = "cm_run_task stop-${1}"
[tasks.start-db]
script_runner = "@duckscript"
script = '''
echo Starting Postgres Database
start_db_out = exec --fail-on-error pg_ctl start -l $LOG_PATH -o "-c listen_addresses= -c unix_socket_directories=$PGHOST" -W
if equals ${start_db_out.code} 0
echo Postgres started successfully! Use $DATABASE_URL to connect
else
echo Failed to start Postgres.\n${start_db_out.stderr}
end
# Give postgres some time to get up; otherwise db existence check fails sometimes
sleep 500
db_name = get_env PGDATABASE
db_exist_check = exec psql -tAc "SELECT 1 FROM pg_database WHERE datname='${db_name}'"
if equals ${db_exist_check.code} 0 and equals ${db_exist_check.stdout} 1
echo Database already exists. Not recreating.
else
echo Creating database: ${db_name}
exec --fail-on-error createdb ${db_name}
end
'''
[tasks.stop-db]
script_runner = "@duckscript"
script = '''
echo Stopping Postgres Database
stop_db_out = exec pg_ctl stop -l $LOG_PATH -o "-c listen_addresses= -c unix_socket_directories=$PGHOST" -W
if equals ${stop_db_out.code} 0
echo Postgres stopped successfully!
else
echo Failed to stop Postgres.\n${stop_db_out.stderr}
end
'''
[tasks.start-minio]
script_runner = "bash"
script = '''
echo Starting minio
mkdir -p ${MINIO_STORAGE_DIR}
minio server ${MINIO_STORAGE_DIR} --quiet &> ${MINIO_STORAGE_DIR}/../LOG &
# mc alias is needed to stop the minio server we pushed to background
until mc alias set local http://localhost:9000 $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD &> /dev/null
do
sleep 1
done
echo Successfully started minio on ${MINIO_SERVER_URL} !
echo Created mc alias 'local'
'''
[tasks.stop-minio]
script_runner = "@duckscript"
script = '''
exec mc admin service stop local
'''
[tasks.start-infra]
dependencies = ["start-db", "start-minio"]
[tasks.stop-infra]
dependencies = ["stop-db", "stop-minio"]