Skip to content

Commit

Permalink
feat: update bigdipper scripts and services
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 4, 2020
1 parent 7300c3a commit 2be854d
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 50 deletions.
41 changes: 0 additions & 41 deletions packages/deployment/bigdipper/ag-bigdipper.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[Unit]
Description=Big Dipper Agoric Explorer
Description=Big Dipper Agoric Testnet Explorer
Requires=network-online.target
After=network-online.target

[Service]
Environment=BIND_IP=127.0.0.1
Environment=PORT=5000
Environment=ROOT_URL=https://explorer-testnet.agoric.com/
Environment=ROOT_URL=https://explorer.testnet.agoric.com/
WorkingDirectory=/home/bigdipper
Restart=on-failure
User=bigdipper
Group=bigdipper
PermissionsStartOnly=true
ExecStart=/home/bigdipper/ag-bigdipper.sh
ExecStart=/home/bigdipper/bigdipper.sh https://testnet.agoric.com
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM

Expand Down
95 changes: 89 additions & 6 deletions packages/deployment/bigdipper/bigdipper.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ server {
listen 80;
return 301 https://$host$request_uri;
}

resolver 1.1.1.1;

server {
# listen 80 default_server;
# listen [::]:80 default_server ipv6only=on;
listen 443;
server_name _; # explorer.testnet.agoric.com;
server_name explorer.testnet.agoric.com;

ssl on;
ssl_certificate /etc/ssl/explorer.testnet.agoric.com.pem;
Expand All @@ -24,18 +25,18 @@ server {


location = /favicon.ico {
root /home/bigdipper/portal/programs/web.browser/app;
root /home/bigdipper/portal-testnet/programs/web.browser/app;
access_log off;
}

location ~* "^/[a-z0-9]{40}\.(css|js)$" {
#gzip_static on;
root /home/bigdipper/portal/programs/web.browser;
root /home/bigdipper/portal-testnet/programs/web.browser;
access_log off;
}

location ~ "^/packages" {
root /home/bigdipper/portal/programs/web.browser;
root /home/bigdipper/portal-testnet/programs/web.browser;
access_log off;
}

Expand All @@ -50,3 +51,85 @@ server {
proxy_set_header Host $host;
}
}

server {
listen 443;
server_name testnet.explorer.agoric.net;

ssl on;
ssl_certificate /etc/ssl/cloudflare-edge-explorer.agoric.net.pem;
ssl_certificate_key /etc/ssl/cloudflare-edge-explorer.agoric.net.key;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;


location = /favicon.ico {
root /home/bigdipper/portal-testnet/programs/web.browser/app;
access_log off;
}

location ~* "^/[a-z0-9]{40}\.(css|js)$" {
#gzip_static on;
root /home/bigdipper/portal-testnet/programs/web.browser;
access_log off;
}

location ~ "^/packages" {
root /home/bigdipper/portal-testnet/programs/web.browser;
access_log off;
}

# pass requests to Meteor
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_ssl_server_name on;
proxy_set_header Upgrade $http_upgrade; #for websockets
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}

server {
listen 443;
server_name hacktheorb.explorer.agoric.net;

ssl on;
ssl_certificate /etc/ssl/cloudflare-edge-explorer.agoric.net.pem;
ssl_certificate_key /etc/ssl/cloudflare-edge-explorer.agoric.net.key;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;


location = /favicon.ico {
root /home/bigdipper/portal-hacktheorb/programs/web.browser/app;
access_log off;
}

location ~* "^/[a-z0-9]{40}\.(css|js)$" {
#gzip_static on;
root /home/bigdipper/portal-hacktheorb/programs/web.browser;
access_log off;
}

location ~ "^/packages" {
root /home/bigdipper/portal-hacktheorb/programs/web.browser;
access_log off;
}

# pass requests to Meteor
location / {
proxy_pass http://127.0.0.1:5001;
proxy_http_version 1.1;
proxy_ssl_server_name on;
proxy_set_header Upgrade $http_upgrade; #for websockets
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
58 changes: 58 additions & 0 deletions packages/deployment/bigdipper/bigdipper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#! /bin/bash
# bigdipper.sh - Run Agoric Big Dipper Explorer
set -e

# Kill off all our children on exit.
trap 'kill $(jobs -p) 2>/dev/null' EXIT

NETWORK_URL=${1-"https://testnet.agoric.com"}
ncf=`curl -Ss "$NETWORK_URL/network-config"`
cn=`echo "$ncf" | jq -r '.chainName'`

origRpcAddrs=( $(echo $ncf | jq -r '.rpcAddrs | join(" ")' ) )

rpcAddrs=(${origRpcAddrs[@]})
rp=
while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
r=$(( $RANDOM % ${#rpcAddrs[@]} ))
selected=${rpcAddrs[$r]}
rpcAddrs=( ${rpcAddrs[@]/$selected} )

ping="curl -s http://$selected/status"
if $ping > /dev/null; then
# Found an active node.
rp=$selected
break
fi
done

if test -z "$rp"; then
echo "Cannot find an active node; last tried $selected"
sleep 20
exit 1
fi

# Network name vs. database name.
nn=`echo "$cn" | sed -e 's/-[0-9].*//'`
db=`echo "$cn" | sed -e 's/\./-/g'`

export MONGO_URL=mongodb://localhost:27017/"$db"
GTM=`cat google-tag-manager.txt || true`

api=`echo "$rp" | sed -e 's/\:.*/:1317/'`

test -d "portal-$cn" && ln -sfT "portal-$cn" "portal-$nn"
cd "portal-$nn"
export METEOR_SETTINGS=`sed -e "s/@GTM@/$GTM/; s/@CHAIN_NAME@/$cn/; s!@NETWORK_URL@!$NETWORK_URL!; s/@RPC@/$rp/; s/@API@/$api/;" settings.json`

# Kill this script if the ping fails.
# Systemd restarts us and we refresh our parameters.
{
while $ping > /dev/null; do
sleep 30
done
kill $$
} &

/usr/bin/node main.js
exit $?

0 comments on commit 2be854d

Please sign in to comment.