-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-and-run
44 lines (39 loc) · 1.18 KB
/
init-and-run
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
#
# MIT License
# Copyright (c) 2022 Darek Bobak
#
# https://github.com/dbobak/TiddlyWiki-Docker/
# based on https://gitlab.com/nicolaw/tiddlywiki
#
# Refer to the canonical online documentation for help:
# - https://tiddlywiki.com/static/Using%2520TiddlyWiki%2520on%2520Node.js.html
# - https://tiddlywiki.com/static/ServerCommand.html
#
# Reign in Node memory consumption:
# - https://github.com/nodejs/node/issues/2738
# - https://nodejs.org/api/cli.html#cli_node_options_options
# - http://fiznool.com/blog/2016/10/01/running-a-node-dot-js-app-in-a-low-memory-environment/
#
set -e
main () {
TW5="$(readlink -f "$(which tiddlywiki)")"
if [ -n "$NODE_MEM" ]; then
NODE_OPTIONS="--max_old_space_size=$(( ( NODE_MEM * 4 ) / 5 )) \
$NODE_OPTIONS"
export NODE_OPTIONS
fi
if [ ! -d "/var/lib/tiddlywiki/$TW_WIKINAME" ]; then
/usr/bin/env node "$TW5" "$TW_WIKINAME" --init server
fi
# shellcheck disable=SC2086
exec /usr/bin/env node $NODE_OPTIONS "$TW5" "$TW_WIKINAME" --server \
"$TW_PORT" \
"$TW_ROOTTIDDLER" \
"$TW_RENDERTYPE" \
"$TW_SERVETYPE" \
"$TW_USERNAME" \
"$TW_PASSWORD" \
"$TW_HOST" \
"$TW_PATHPREFIX"
}
main "$@"