blob: 9e6827fb79231026535e235726ca375d1b58b499 (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#!/bin/sh
# -*- coding: utf-8 -*-
basedir="$(realpath "$0" | xargs dirname)"
info()
{
echo "--- $*"
}
error()
{
echo "=== ERROR: $*" >&2
}
warning()
{
echo "=== WARNING: $*" >&2
}
die()
{
error "$*"
exit 1
}
cleanup()
{
[ -n "$pid_backd" ] && kill "$pid_backd" 2>/dev/null
[ -n "$pid_postd" ] && kill "$pid_postd" 2>/dev/null
[ -n "$pid_fsd" ] && kill "$pid_fsd" 2>/dev/null
wait
}
cleanup_and_exit()
{
cleanup
exit 1
}
trap cleanup_and_exit INT TERM
trap cleanup EXIT
start_fsd()
{
echo "Starting cms-fsd..."
rm -f "$rundir/cms-fsd.sock"
local binary="$target/cms-fsd"
[ -x "$binary" ] || die "cms-fsd binary $binary not found."
"$binary" \
--rundir "$rundir" \
--no-systemd \
"$dbdir" \
&
pid_fsd=$!
}
start_postd()
{
echo "Starting cms-postd..."
rm -f "$rundir/cms-postd.sock"
local binary="$target/cms-postd"
[ -x "$binary" ] || die "cms-postd binary $binary not found."
"$binary" \
--rundir "$rundir" \
--no-systemd \
"$dbdir" \
&
pid_postd=$!
}
start_backd()
{
echo "Starting cms-backd..."
rm -f "$rundir/cms-backd.sock"
local binary="$target/cms-backd"
[ -x "$binary" ] || die "cms-backd binary $binary not found."
"$binary" \
--rundir "$rundir" \
--no-systemd \
&
pid_backd=$!
}
release="debug"
while [ $# -ge 1 ]; do
case "$1" in
--debug|-d)
release="debug"
;;
--release|-r)
release="release"
;;
*)
die "Invalid option: $1"
;;
esac
shift
done
target="$basedir/../target/$release"
rundir="$basedir/run"
dbdir="$basedir/../example/db"
pid_fsd=
pid_postd=
pid_backd=
mkdir -p "$rundir"
start_fsd
start_postd
sleep 1
start_backd
wait
# vim: ts=4 sw=4 expandtab
|