BlockExplorer.nu is now open source

Yea, sounds like a good place to start. I’ll post my progress in this post.

1 Like

Please push the latest code to github, without it we can’t proceed.

Alright, after trying to build the explorer from the repo, there were a few things that went wrong.

First off, python-bitcoinrpc was bugged when I tried installing it with pip install python-bitcoinrpc. Instead, I had to use pip install git+https://github.com/jgarzik/python-bitcoinrpc.git.

Secondly, the docs were not as clear as I thought they were so I made some changes that should help. Specifically, how to start a mongodb daemon and its shell.

Finally, I made changes to the NuParserv007.py script so that it works on initial run, inserting the first 10 blocks of the blockchain into the db.

Hence, with the updated changes, I was able to clone the explorer with success. Check out the changes in the repo and clone this updated version for a clean slate.

As always, feel free to raise issues on github and ask questions in the chatroom on gitter.

Cheers.

5 Likes

Where is the best place to get nu-specific API info? Thanks @JetJet13

Hey @mhps, there is no official documentation up, so the best option right now is to simply use the urls located in server.js to figure out what parameters you need.

Note that all public api’s start with /api/v1. ie) http://blockexplorer.nu/api/v1/blocklatest/

Thanks. That was what I did when writing a watch dog script to restart the explorer when it is down.
Is it possible to remotely restart the explorer with a one-line shell command?

Not to my knowledge, no. Is that wise ?

Authentication isn’t compromised and no need to have passwd stored on the disk e.g.

#!/bin/sh
echo type in passwd from console
passwd=`cat`

# startwatch dog
nohup watchdog $passwd &

In the watchdog script

...
# watch dog resets the server
echo $password | ssh   restart_user@ip resetting_command
...

run this script and enter the passwd from console once during start up. after the terminal is closed passwd cannot be seen or retrieved.

Interesting concept. However, I think an easier solution would be to make a bash script on the server itself that restarts the explorer every x minutes. I’ll implement one today.

Thanks for the suggestion.
Cheers.

Edit: Just finished implementing a bash script that restarts the explorer every 15min.

1 Like

Every 15m seems too often. How much time does the server remain unresponsive in a restart? I think check if the block height every 10min and do a forced restart every 6 hours is good.

The server restarts in a few seconds so it’s not that important how often I restart it. However, why restart something that is working fine; I’ll make some changes to the script.

Cheers.

1 Like

Alright, here’s the new bash script. It checks http response code (either 200 or 404) every 15min. and restarts the server if response is 404.

Edit: formatting


#!/bin/bash
clear
while true; do
    block=$(curl -sLI -w "%{http_code}" "http://blockexplorer.nu/api/v1/blocklatest/" -o /dev/null)
    echo $block
    if [ $block == 404  ]; then
            echo "Explorer is down; Restarting Explorer"
            pm2 restart server # pm2 will restart the server
    else
            echo "Explorer is up and running."
    fi
    sleep 900 # 15min
done
4 Likes

@JetJet13 it looks like blockexplorer.nu is down. Aren’t you on contract to keep it up?

@backpacker the block explorer you host is 3 days behind. Can you fix it please?

Hey Phoenix,

My contract with the NuBits team finished quite a while ago. I open sourced the project in Jan. 2016 to put the block explorer in the hands of the community.

However, I will note that it was only until recently that the server went down and the domain expired for blockexplorer.nu.

@JetJet13 you are correct. It was your current contract to provide block explorer service for B&C Exchange that was my source of confusion.

No problem at all,

Happy Holidays!

1 Like