diff --git a/backend/package.json b/backend/package.json index 5ad6ad42f..84d8d31ac 100644 --- a/backend/package.json +++ b/backend/package.json @@ -22,6 +22,7 @@ "scripts": { "build": "tsc", "start": "npm run build && node dist/index.js", + "production": "until false;do npm install;npm run build;node dist/index.js;sleep 1;done", "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { diff --git a/production/README.md b/production/README.md new file mode 100644 index 000000000..5e9f55969 --- /dev/null +++ b/production/README.md @@ -0,0 +1 @@ +### misc scripts for running mempool.space production site diff --git a/production/mempool-config.liquid.json b/production/mempool-config.liquid.json new file mode 100644 index 000000000..5f7f3ee05 --- /dev/null +++ b/production/mempool-config.liquid.json @@ -0,0 +1,19 @@ +{ + "HTTP_PORT": 8998, + "DB_HOST": "localhost", + "DB_PORT": 3306, + "DB_USER": "lmempool", + "DB_PASSWORD": "lmempool", + "DB_DATABASE": "lmempool", + "API_ENDPOINT": "/api/v1/", + "ELECTRS_POLL_RATE_MS": 2000, + "MEMPOOL_REFRESH_RATE_MS": 2000, + "DEFAULT_PROJECTED_BLOCKS_AMOUNT": 8, + "KEEP_BLOCK_AMOUNT": 24, + "INITIAL_BLOCK_AMOUNT": 8, + "TX_PER_SECOND_SPAN_SECONDS": 150, + "ELECTRS_API_URL": "http://[::1]:3001", + "SSL": false, + "SSL_CERT_FILE_PATH": "/etc/letsencrypt/live/mysite/fullchain.pem", + "SSL_KEY_FILE_PATH": "/etc/letsencrypt/live/mysite/privkey.pem" +} diff --git a/production/mempool-config.mainnet.json b/production/mempool-config.mainnet.json new file mode 100644 index 000000000..a51cc38d5 --- /dev/null +++ b/production/mempool-config.mainnet.json @@ -0,0 +1,19 @@ +{ + "HTTP_PORT": 8999, + "DB_HOST": "localhost", + "DB_PORT": 3306, + "DB_USER": "mempool", + "DB_PASSWORD": "mempool", + "DB_DATABASE": "mempool", + "API_ENDPOINT": "/api/v1/", + "ELECTRS_POLL_RATE_MS": 2000, + "MEMPOOL_REFRESH_RATE_MS": 2000, + "DEFAULT_PROJECTED_BLOCKS_AMOUNT": 8, + "KEEP_BLOCK_AMOUNT": 24, + "INITIAL_BLOCK_AMOUNT": 8, + "TX_PER_SECOND_SPAN_SECONDS": 150, + "ELECTRS_API_URL": "http://[::1]:3000", + "SSL": false, + "SSL_CERT_FILE_PATH": "/etc/letsencrypt/live/mysite/fullchain.pem", + "SSL_KEY_FILE_PATH": "/etc/letsencrypt/live/mysite/privkey.pem" +} diff --git a/production/mempool-config.testnet.json b/production/mempool-config.testnet.json new file mode 100644 index 000000000..cbe96a314 --- /dev/null +++ b/production/mempool-config.testnet.json @@ -0,0 +1,19 @@ +{ + "HTTP_PORT": 8997, + "DB_HOST": "localhost", + "DB_PORT": 3306, + "DB_USER": "tmempool", + "DB_PASSWORD": "tmempool", + "DB_DATABASE": "tmempool", + "API_ENDPOINT": "/api/v1/", + "ELECTRS_POLL_RATE_MS": 2000, + "MEMPOOL_REFRESH_RATE_MS": 2000, + "DEFAULT_PROJECTED_BLOCKS_AMOUNT": 8, + "KEEP_BLOCK_AMOUNT": 24, + "INITIAL_BLOCK_AMOUNT": 8, + "TX_PER_SECOND_SPAN_SECONDS": 150, + "ELECTRS_API_URL": "http://[::1]:3002", + "SSL": false, + "SSL_CERT_FILE_PATH": "/etc/letsencrypt/live/mysite/fullchain.pem", + "SSL_KEY_FILE_PATH": "/etc/letsencrypt/live/mysite/privkey.pem" +} diff --git a/production/mempool-install-all b/production/mempool-install-all new file mode 100755 index 000000000..0f9a17717 --- /dev/null +++ b/production/mempool-install-all @@ -0,0 +1,12 @@ +#!/usr/local/bin/zsh +for site in mainnet liquid testnet +do + git clone https://github.com/mempool/mempool "${HOME}/${site}" + cd "${HOME}/${site}/backend/" + cp "../production/mempool-config.${site}.json" "mempool-config.json" + npm install + npm run build + cd "${HOME}/${site}/frontend/" + npm install + npm run build +done diff --git a/production/mempool-start-all b/production/mempool-start-all new file mode 100755 index 000000000..27fa971cd --- /dev/null +++ b/production/mempool-start-all @@ -0,0 +1,9 @@ +#!/usr/local/bin/zsh +for site in mainnet liquid testnet +do + cd "${HOME}/${site}/backend/" + screen -dmS "${site}" npm run production +done + +#cd "${HOME}/webhook/" +#screen -dmS webhook ./start diff --git a/production/mempool-upgrade-all b/production/mempool-upgrade-all new file mode 100755 index 000000000..06ee9e031 --- /dev/null +++ b/production/mempool-upgrade-all @@ -0,0 +1,25 @@ +#!/usr/local/bin/zsh -x +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$HOME/bin + +[ -f $HOME/lock ] && exit 1 +touch $HOME/lock + +echo 'rebuilding mempool sites'|wall + +for site in mainnet liquid testnet +do + cd "$HOME/${site}" + git pull origin master + hash=$(git rev-parse HEAD) + cd "$HOME/${site}/frontend" + npm run build + rsync -av ./dist/mempool/* "${HOME}/public_html/${site}/" + cd "$HOME/${site}/backend" + npm run build +done + +ps uaxw|grep 'node dist/index'|grep -v grep|awk '{print $2}'|xargs -n 1 kill + +keybase chat send --channel dev mempool "All mempool sites updated to ${hash}" + +rm "$HOME/lock" diff --git a/nginx-wiz.conf b/production/nginx.conf similarity index 100% rename from nginx-wiz.conf rename to production/nginx.conf diff --git a/sitemap-update b/production/sitemap-update similarity index 100% rename from sitemap-update rename to production/sitemap-update