-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart-rtappdotio
executable file
·59 lines (47 loc) · 1.82 KB
/
start-rtappdotio
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
#!/bin/bash
# Production sutff, these should be habdled on npm run dev
migrateDb() {
npm run migrate
}
buildFrontend() {
echo "==> Rebuilding static pages..."
npm run build
}
configDebugger() {
echo "config-debugger: Postgres - postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
echo "config-debugger: Redis - redis://${REDIS_USER}:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}"
}
main() {
if [[ $RAILWAY_STATIC_URL != "" ]]; then
echo "==> Railway installation detected, grabbing Postgres and"
echo " Redis configuration..."
# Postgres
export DB_HOST=${PGHOST} DB_PORT=${PGPORT} DB_NAME=${PGDATABASE} DB_PASSWORD=${PGPASSWORD} DB_USER=${PGUSER}
# Redis
export REDIS_PASSWORD=${REDISPASSWORD} REDIS_PORT=${REDISPORT} REDIS_USER=${REDISUSER} REDIS_HOST=${REDISHOST}
fi
if [[ $1 == "dev" ]] || [[ $1 == "develop" ]] || [[ $NODE_ENV == "development" ]]; then
configDebugger && migrateDb
echo "==> Running in devmode..."
npm run dev
elif [[ $1 == "production" ]] || [[ $1 == "prod" ]] || [[ $NODE_ENV == "production" ]]; then
migrateDb
if [[ $FORCE_REBUILD_CLIENT != "" ]]; then
buildFrontend
fi
configDebugger && migrateDb
echo "==> Running in production..."
npm run start
else
echo "Supported options:"
echo " prod, production Run in production, with only database migrations"
echo " prod-build, production-build Run in production, plus build static pages first."
echo " dev, develop, development Run in development, with Nodemon."
echo ""
echo "Available variables:"
echo " NODE_ENV Used for detecting modes, especially in PaaS services"
echo " FORCE_REBUILD_CLIENT Force the script to rebuild client-side pages"
exit
fi
}
main "$@"