-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduction_server
executable file
·91 lines (79 loc) · 2.06 KB
/
production_server
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
#!/bin/bash -e
THIS_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
cd "${THIS_DIR}"
mkdir -p ./data
declare CUBING_JSON GUESTBOOK_JSON_PATH
CUBING_JSON="${THIS_DIR}/data/cubing.json"
GUESTBOOK_JSON_PATH="${THIS_DIR}/data/guestbook.json"
./generate_build_hash || exit $?
declare -rx CUBING_JSON GUESTBOOK_JSON_PATH
if [[ ! -e "${CUBING_JSON}" ]]; then
printf "%s JSON file doesn't exist\n" "${CUBING_JSON}" 1>&2
exit 1
fi
# if there are no extra guestbok comments, just create an file with '[]' as the contents
if [[ ! -e "${GUESTBOOK_JSON_PATH}" ]]; then
printf "%s JSON file doesn't exist\n" "${GUESTBOOK_JSON_PATH}" 1>&2
exit 1
fi
declare GLUE_DATABASE_PATH GLUE_SECRET_KEY_BASE MIX_ENV
GLUE_DATABASE_PATH="${THIS_DIR}/data/prod.sqlite"
GLUE_SECRET_KEY_BASE="${GLUE_SECRET_KEY_BASE?:No GLUE_SECRET_KEY_BASE set}"
MIX_ENV=prod
export GLUE_DATABASE_PATH GLUE_SECRET_KEY_BASE MIX_ENV
case "$1" in
# drop into an interactive shell after loading environment secrets
--shell)
echo "Dropping into interactive shell with secrets..."
bash
exit 0
;;
--iex)
# drop into iex after loading environment secrets
iex -S mix
exit 0
;;
--epochs)
mix run -e Glue.PageHits.page_hit_epochs || exit $?
exit 0
;;
--approve-comments)
# approve any new comments
mix run -e Glue.GuestBookComments.CLI.main || exit $?
exit 0
;;
--review-comments)
# re-approve/deny all comments
mix run -e Glue.GuestBookComments.CLI.all || exit $?
exit 0
;;
--print-count)
mix run -e Glue.GuestBookComments.CLI.new_count || exit $?
exit 0
;;
--print-new-comments)
mix run -e Glue.GuestBookComments.CLI.print_new_comments || exit $?
exit 0
;;
--edit-comment)
mix run -e Glue.GuestBookComments.CLI.edit_comment || exit $?
exit 0
;;
--run)
:
;;
*)
echo "Must specify one of:"
grep -P '^\s*--?[\w-]+\)' "$(realpath "$0")" | tr -d '); '
exit 1
;;
esac
mix deps.get --only prod
mix compile
mix phx.digest.clean
cd ./assets
# allowed for react-canvas-draw, can maybe remove "paint" window if this gets to be an issue
npm install --legacy-peer-deps
npm run deploy
cd "${THIS_DIR}"
exec mix glue.prod.server