summaryrefslogtreecommitdiff
path: root/catlfish-dev/start.sh
blob: e651fae7d1475e683c0511d9754361a8ff16d4c1 (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
#! /bin/sh

# Required arguments.
logname=$1; [ -n "$1" ] && shift
role=$1; [ -n "$1" ] && shift
nodename=$1; [ -n "$1" ] && shift

# Optional arguments.
erlbase=$ERLANG_BASE_DIR

# Use some reasonable default values.
[ -z "$erlbase" ] && erlbase=/usr/local/catlfish

# FIXME: Get getconfig.sh from the
# $erlbase/lib/catlfish-$VERSION.ez (zip archive) instead of requiring
# source code to be unpacked in the container.
GETCONFIG=/usr/local/catlfish/src/tools/getconfig.sh

mkdir ${nodename}
$GETCONFIG /usr/local/etc/catlfish/${nodename}.cfg ${logname}.cfg force-compile
ln -s ${nodename}/${nodename}.config

case $role in
    frontend|storage|signing)
        boot=catlfish
        ;;

    merge)
	[ -z "${MERGE_DB_DIR}" ] && MERGE_DB_DIR=merge-db
        $erlbase/merge.sh ${logname} ${nodename} \
                          > merge_log/stdout \
                          2> merge_log/stderr &
        boot=merge
        ;;

    status)
        boot=statusserver
        ;;

    *)
        echo "catlfish: unknown role: $role"
        exit 1
        ;;
esac

$erlbase/bin/run_erl \
    /var/run/catlfish/ \
    /var/run/catlfish/erlang_log/ \
    "exec $erlbase/bin/erl -boot $boot -config $nodename"