Update misc files used for mempool.space production website
This commit is contained in:
1
production/README.md
Normal file
1
production/README.md
Normal file
@@ -0,0 +1 @@
|
||||
### misc scripts for running mempool.space production site
|
||||
19
production/mempool-config.liquid.json
Normal file
19
production/mempool-config.liquid.json
Normal file
@@ -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"
|
||||
}
|
||||
19
production/mempool-config.mainnet.json
Normal file
19
production/mempool-config.mainnet.json
Normal file
@@ -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"
|
||||
}
|
||||
19
production/mempool-config.testnet.json
Normal file
19
production/mempool-config.testnet.json
Normal file
@@ -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"
|
||||
}
|
||||
12
production/mempool-install-all
Executable file
12
production/mempool-install-all
Executable file
@@ -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
|
||||
9
production/mempool-start-all
Executable file
9
production/mempool-start-all
Executable file
@@ -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
|
||||
25
production/mempool-upgrade-all
Executable file
25
production/mempool-upgrade-all
Executable file
@@ -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"
|
||||
216
production/nginx.conf
Normal file
216
production/nginx.conf
Normal file
@@ -0,0 +1,216 @@
|
||||
user nobody;
|
||||
pid /var/run/nginx.pid;
|
||||
include /usr/local/etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
worker_processes auto;
|
||||
worker_rlimit_nofile 9999;
|
||||
|
||||
events {
|
||||
worker_connections 9000;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 300s;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
include /usr/local/etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
proxy_cache off;
|
||||
|
||||
gzip on;
|
||||
gzip_comp_level 5;
|
||||
gzip_min_length 256;
|
||||
gzip_proxied any;
|
||||
gzip_vary on;
|
||||
|
||||
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # text/html is always compressed by gzip module
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name mempool.space;
|
||||
|
||||
if ($host = mempool.space) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name mempool.ninja;
|
||||
|
||||
if ($host = mempool.ninja) {
|
||||
return 301 https://mempool.space$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
listen [::]:443 ssl http2; # managed by Certbot
|
||||
listen 443 ssl http2; # managed by Certbot
|
||||
|
||||
ssl_certificate /usr/local/etc/letsencrypt/live/mempool.ninja/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /usr/local/etc/letsencrypt/live/mempool.ninja/privkey.pem; # managed by Certbot
|
||||
include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
|
||||
server_name mempool.ninja; # managed by Certbot
|
||||
|
||||
return 301 https://mempool.space$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name liquid.mempool.ninja;
|
||||
|
||||
if ($host = liquid.mempool.ninja) {
|
||||
return 301 https://mempool.space/liquid$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
listen [::]:443 ssl http2; # managed by Certbot
|
||||
listen 443 ssl http2; # managed by Certbot
|
||||
|
||||
ssl_certificate /usr/local/etc/letsencrypt/live/liquid.mempool.ninja/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /usr/local/etc/letsencrypt/live/liquid.mempool.ninja/privkey.pem; # managed by Certbot
|
||||
include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
|
||||
server_name liquid.mempool.ninja; # managed by Certbot
|
||||
|
||||
return 301 https://mempool.space/liquid$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name testnet.mempool.ninja;
|
||||
|
||||
if ($host = testnet.mempool.ninja) {
|
||||
return 301 https://mempool.space/testnet$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
listen [::]:443 ssl http2; # managed by Certbot
|
||||
listen 443 ssl http2; # managed by Certbot
|
||||
|
||||
ssl_certificate /usr/local/etc/letsencrypt/live/testnet.mempool.ninja/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /usr/local/etc/letsencrypt/live/testnet.mempool.ninja/privkey.pem; # managed by Certbot
|
||||
include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
|
||||
server_name testnet.mempool.ninja; # managed by Certbot
|
||||
|
||||
return 301 https://mempool.space/testnet$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:81;
|
||||
listen [::]:443 ssl default http2; # managed by Certbot
|
||||
listen 443 ssl default http2; # managed by Certbot
|
||||
|
||||
ssl_certificate /usr/local/etc/letsencrypt/live/mempool.space/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /usr/local/etc/letsencrypt/live/mempool.space/privkey.pem; # managed by Certbot
|
||||
include /usr/local/etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /usr/local/etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
|
||||
root /mempool/public_html/mainnet/;
|
||||
|
||||
index index.html index.htm index.nginx-debian.html;
|
||||
server_name mempool.space; # managed by Certbot
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html =404;
|
||||
}
|
||||
|
||||
location /explorer {
|
||||
rewrite /explorer/(.*) https://$host/$1 permanent;
|
||||
}
|
||||
|
||||
location /webhook {
|
||||
proxy_pass http://127.0.0.1:2222/;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://127.0.0.1:8999/api;
|
||||
}
|
||||
|
||||
location /api/mainnet {
|
||||
proxy_pass http://127.0.0.1:8999/api;
|
||||
}
|
||||
|
||||
location /api/liquid {
|
||||
proxy_pass http://127.0.0.1:8998/api;
|
||||
}
|
||||
|
||||
location /api/testnet {
|
||||
proxy_pass http://127.0.0.1:8997/api;
|
||||
}
|
||||
|
||||
location /electrs/ {
|
||||
proxy_pass http://[::1]:3000/;
|
||||
}
|
||||
|
||||
location /electrs/mainnet/ {
|
||||
proxy_pass http://[::1]:3000/;
|
||||
}
|
||||
|
||||
location /electrs/liquid/ {
|
||||
proxy_pass http://[::1]:3001/;
|
||||
}
|
||||
|
||||
location /electrs/testnet/ {
|
||||
proxy_pass http://[::1]:3002/;
|
||||
}
|
||||
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:8999/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
}
|
||||
|
||||
location /ws/mainnet {
|
||||
proxy_pass http://127.0.0.1:8999/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
}
|
||||
|
||||
location /ws/liquid {
|
||||
proxy_pass http://127.0.0.1:8998/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
}
|
||||
|
||||
location /ws/testnet {
|
||||
proxy_pass http://127.0.0.1:8997/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
}
|
||||
}
|
||||
}
|
||||
69
production/sitemap-update
Executable file
69
production/sitemap-update
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env zsh
|
||||
SITEMAP_TEMP_FILE=temp.xml
|
||||
|
||||
BLOCK_TIP_HEIGHT="$(curl -s https://mempool.space/electrs/mainnet/blocks/tip/height)"
|
||||
BLOCK_HEIGHT=0
|
||||
BLOCK_PER_FILE=100
|
||||
|
||||
FILE_TOTAL="$(($BLOCK_TIP_HEIGHT / $BLOCK_PER_FILE))"
|
||||
FILE_START=1
|
||||
FILE_STOP="${FILE_TOTAL}"
|
||||
FILE="${FILE_START}"
|
||||
|
||||
echo "${BLOCK_TIP_HEIGHT} blocks"
|
||||
echo "${BLOCK_PER_FILE} blocks per sitemap"
|
||||
echo "${FILE_TOTAL} total sitemaps"
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' > "${SITEMAP_TEMP_FILE}"
|
||||
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' >> "${SITEMAP_TEMP_FILE}"
|
||||
|
||||
until [ "${FILE}" = "${FILE_STOP}" ];do
|
||||
|
||||
BLOCK_HEIGHT=$((($FILE * $BLOCK_PER_FILE) - 1))
|
||||
if [ "${BLOCK_HEIGHT}" -gt "${BLOCK_TIP_HEIGHT}" ];then
|
||||
BLOCK_HEIGHT="${BLOCK_TIP_HEIGHT}"
|
||||
fi
|
||||
BLOCK_HASH=$(curl -s https://mempool.space/electrs/mainnet/block-height/${BLOCK_HEIGHT})
|
||||
BLOCK=$(curl -s https://mempool.space/electrs/mainnet/block/${BLOCK_HASH})
|
||||
BLOCK_TIMESTAMP=$(echo "${BLOCK}"|sed -e 's/.*timestamp.://' -e 's/,.*//')
|
||||
|
||||
SITEMAP_FILE=$(printf "sitemap/%05d.xml" "${FILE}")
|
||||
SITEMAP_LASTMOD=$(date -r "${BLOCK_TIMESTAMP}" +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
if [ ! -f "${SITEMAP_FILE}" ] || [ "${BLOCK_HEIGHT}" -gt $(($BLOCK_TIP_HEIGHT - 2000)) ];then
|
||||
|
||||
BLOCK_STOP="$((($BLOCK_HEIGHT - ${BLOCK_PER_FILE}) + 1))"
|
||||
echo "generating ${SITEMAP_FILE} for block ${BLOCK_STOP} ~ ${BLOCK_HEIGHT}"
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' > "${SITEMAP_FILE}"
|
||||
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' >> "${SITEMAP_FILE}"
|
||||
|
||||
while [ "${BLOCK_HEIGHT}" -ge "${BLOCK_STOP}" ];do
|
||||
|
||||
BLOCK_HASH=$(curl -s https://mempool.space/electrs/mainnet/block-height/${BLOCK_HEIGHT})
|
||||
BLOCK=$(curl -s https://mempool.space/electrs/mainnet/block/${BLOCK_HASH})
|
||||
BLOCK_TIMESTAMP=$(echo "${BLOCK}"|sed -e 's/.*timestamp.://' -e 's/,.*//')
|
||||
BLOCK_LASTMOD=$(date -r "${BLOCK_TIMESTAMP}" +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
echo '<url>' >> "${SITEMAP_FILE}"
|
||||
echo "<loc>https://mempool.space/block/${BLOCK_HASH}</loc>" >> "${SITEMAP_FILE}"
|
||||
echo "<lastmod>${BLOCK_LASTMOD}</lastmod>" >> "${SITEMAP_FILE}"
|
||||
echo '</url>' >> "${SITEMAP_FILE}"
|
||||
|
||||
((BLOCK_HEIGHT--))
|
||||
done
|
||||
|
||||
echo '</urlset>' >> "${SITEMAP_FILE}"
|
||||
fi
|
||||
|
||||
echo '<sitemap>' >> "${SITEMAP_TEMP_FILE}"
|
||||
echo "<loc>https://mempool.space/${SITEMAP_FILE}</loc>" >> "${SITEMAP_TEMP_FILE}"
|
||||
echo "<lastmod>${SITEMAP_LASTMOD}</lastmod>" >> "${SITEMAP_TEMP_FILE}"
|
||||
echo '</sitemap>' >> "${SITEMAP_TEMP_FILE}"
|
||||
|
||||
((FILE++))
|
||||
|
||||
done
|
||||
|
||||
echo '</sitemapindex>' >> "${SITEMAP_TEMP_FILE}"
|
||||
mv "${SITEMAP_TEMP_FILE}" "sitemap.xml"
|
||||
Reference in New Issue
Block a user