67 lines
1.5 KiB
Bash
Executable File
67 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Conditional installations based on STORAGE_TYPE
|
|
case "${STORAGE_TYPE}" in
|
|
"redis")
|
|
echo "Installing Redis..."
|
|
npm install redis
|
|
;;
|
|
"postgres")
|
|
echo "Installing PostgreSQL..."
|
|
npm install pg
|
|
;;
|
|
"memcached")
|
|
echo "Installing Memcached..."
|
|
npm install memcached
|
|
;;
|
|
"rethinkdb")
|
|
echo "Installing RethinkDB..."
|
|
npm install rethinkdbdash
|
|
;;
|
|
esac
|
|
|
|
# If TEST_MODE is true, install Mocha and run tests
|
|
if [ "$TEST_MODE" = "true" ]; then
|
|
echo "Installing Mocha for testing..."
|
|
npm install mocha
|
|
echo "Running tests..."
|
|
npm test
|
|
else
|
|
# Normal startup
|
|
# Generate config.js from environment variables
|
|
cat > config.js <<EOF
|
|
{
|
|
"host": "${HOST:-0.0.0.0}",
|
|
"port": ${PORT:-7777},
|
|
"keyLength": ${KEY_LENGTH:-10},
|
|
"maxLength": ${MAX_LENGTH:-400000},
|
|
"staticMaxAge": ${STATIC_MAX_AGE:-7776000},
|
|
"recompressStaticAssets": ${RECOMPRESS_STATIC_ASSETS:-true},
|
|
"logging": [
|
|
{
|
|
"level": "${LOGGING_LEVEL:-verbose}",
|
|
"type": "${LOGGING_TYPE:-Console}",
|
|
"colorize": ${LOGGING_COLORIZE:-false}
|
|
}
|
|
],
|
|
"keyGenerator": {
|
|
"type": "${KEY_GENERATOR_TYPE:-phonetic}"
|
|
},
|
|
"storage": {
|
|
"type": "${STORAGE_TYPE:-redis}",
|
|
"path": "${STORAGE_PATH:-./data}",
|
|
"host": "${STORAGE_HOST:-haste_redis}",
|
|
"port": ${STORAGE_PORT:-6379},
|
|
"db": ${STORAGE_DB:-2},
|
|
"expire": ${STORAGE_EXPIRE:-2592000}
|
|
},
|
|
"documents": {
|
|
"about": "./about.md"
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# Start the server
|
|
exec node server.js
|
|
fi
|