diff --git a/README.md b/README.md index a2f287501..2f9e1eaa6 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,9 @@ $ cd blockchain-explorer/app $ createdb `whoami` ``` -Connect to the PostgreSQL database and run DB status commands: +Connect to the PostgreSQL database and run DB status commands. To export the +settings from `app/explorerconfig.json` to the environment, run `source +app/exportConfig.sh`; this will set `$DATABASE_DATABASE` and related envvars. * **Ubuntu** @@ -373,7 +375,7 @@ $ npm run build ``` * `npm start` - * It will have the backend and GUI service up + * It will have the backend and GUI service up, for as long as the process runs * `npm run app-stop` * It will stop the node server diff --git a/app/exportConfig.sh b/app/exportConfig.sh new file mode 100644 index 000000000..9900cec90 --- /dev/null +++ b/app/exportConfig.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "should be sourced" +jq . ./explorerconfig.json >/dev/null + +export DATABASE_HOST=$(jq -r '.postgreSQL.host' ./explorerconfig.json) +export DATABASE_PORT=$(jq -r '.postgreSQL.port' ./explorerconfig.json) +export DATABASE_USERNAME=$(jq -r '.postgreSQL.username' ./explorerconfig.json) +export DATABASE_DATABASE=$(jq -r '.postgreSQL.database' ./explorerconfig.json) +export DATABASE_PASSWD=$(jq -r '.postgreSQL.passwd' ./explorerconfig.json) diff --git a/start.sh b/start.sh index 14ec6a6e8..485434bf3 100755 --- a/start.sh +++ b/start.sh @@ -20,4 +20,11 @@ export LOG_CONSOLE_STDOUT=${LOG_CONSOLE_STDOUT:-false} export DISCOVERY_AS_LOCALHOST=${DISCOVERY_AS_LOCALHOST:-true} export EXPLORER_APP_ROOT=${EXPLORER_APP_ROOT:-dist} +function log_exit() { + echo "Server stopped" + exit +} +trap log_exit SIGINT EXIT +echo "Server running..." + node ${EXPLORER_APP_ROOT}/main.js name - hyperledger-explorer