forked from daniloc/airtable-api-proxy
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstart
executable file
·28 lines (22 loc) · 1.08 KB
/
start
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
#!/bin/bash
# bash (re)start script
# - makes sure correct version of node is running
# - checks to see if pm2 and redis are already running, and if so, shuts them down
# - starts redis-server using config file with daemonize=yes
# - checks for a successful client connection to redis-server using the redis-cli
# - if connection has been established, server is (re)started using pm2 in cluster mode, with some options for graceful shutdown/startup
# - if connection cannot be established, exit with error
# - use your own redis and server directory locations
REDIS_DIR="redis-stable"
SERVER_DIR="/home/cabox/workspace"
# - required on my particular VM setup, which keeps resetting the node version
nvm use 14.15.1
[ ! -z "$(ps -ax | grep pm2 | grep -v grep)" ] && pm2 stop "server.js";
[ ! -z "$(ps -ax | grep redis | grep -v grep)" ] && redis-cli shutdown;
redis-server "${REDIS_DIR}/redis.conf" &
if [[ `redis-cli ping` = 'PONG' ]]; then
pm2 start "server.js" -i 3 --wait-ready --listen-timeout 3000 --kill-timeout 6000 --update-env
else
echo "Redis server is not running."
exit 111
fi