]> git.immae.eu Git - perso/Immae/Config/Ansible.git/blame - roles/contexts/fretlink/files/workdir/start
New configuration as of 2019-08-21
[perso/Immae/Config/Ansible.git] / roles / contexts / fretlink / files / workdir / start
CommitLineData
397c4fed
IB
1#!/bin/bash
2
3APP="$1"
80ed46d4 4shift
397c4fed
IB
5
6if [ -z "$APP" ]; then
7 if [ $(dirname $(pwd)) = "$HOME/workdir" ]; then
8 APP=$(basename $(pwd))
9 else
10 echo "need an app to start"
11 exit 1
12 fi
13fi
14
80ed46d4 15if [ "$APP" != "psql" -a "$APP" != "pg_restore" ]; then
397c4fed
IB
16 cd $HOME/workdir/$APP
17 source ../environment
80ed46d4
IB
18elif [ "$APP" = "pg_restore" ]; then
19 source ../environment
20 APP=pg_restore
397c4fed
IB
21else
22 source ../environment
23 APP=psql
24fi
25
26function start_stack() {
27 stack exec $1;
28}
29
30function start_app() {
31 trap 'make stop' EXIT
32
33 if ! docker top mongo_container 2>/dev/null; then
501e9127 34 docker run -d --name mongo_container -p 27017:27017 --rm -v $(pwd)/appdata:/data/db mongo:3.6-hacker
397c4fed
IB
35 echo "Waiting until mongo is started"
36 sleep 10
37 fi
38
39 make start
40 make --directory=frontend/ start
41}
42
43function start_psql() {
44 export PGPASSWORD=$POSTGRESQL_ADDON_PASSWORD
45 psql -h $POSTGRESQL_ADDON_HOST -p $POSTGRESQL_ADDON_PORT -U $POSTGRESQL_ADDON_USER -d $POSTGRESQL_ADDON_DB
46}
47
80ed46d4
IB
48function start_pg_restore() {
49 export PGPASSWORD=$POSTGRESQL_ADDON_PASSWORD
50 pg_restore -h $POSTGRESQL_ADDON_HOST -p $POSTGRESQL_ADDON_PORT -U $POSTGRESQL_ADDON_USER -d $POSTGRESQL_ADDON_DB
51}
52
a6a71ceb 53case "$APP${FLAVOR:+-}$FLAVOR" in
397c4fed 54 "psql") start_psql;;
80ed46d4 55 "pg_restore") start_pg_restore;;
397c4fed
IB
56 "app") start_app;;
57 "admin-root") start_stack server;;
80ed46d4 58 "admin-user") start_stack server;;
397c4fed
IB
59 "carrier-directory") start_stack server;;
60 "freight") start_stack freight-server;;
61 "notifier") start_stack notifier-exe;;
a6a71ceb 62 "notifier-amqp") start_stack notifier-exe-amqp;;
397c4fed 63 "pricer") start_stack pricer;;
80ed46d4 64 "third-parties") start_stack server;;
397c4fed
IB
65 "toolbox") start_stack toolbox-api;;
66esac