Skip to content

Instantly share code, notes, and snippets.

@metachris
Last active July 26, 2018 16:17
Show Gist options
  • Save metachris/2be27cdff9503ebe7db1c27bfc60e435 to your computer and use it in GitHub Desktop.
Save metachris/2be27cdff9503ebe7db1c27bfc60e435 to your computer and use it in GitHub Desktop.
Setting up a neo-python based api-server

See also:

Start a server (eg. based on Ubuntu 17.10)

Basic system setup

sudo su
apt-get update
apt-get -y upgrade

useradd -m node
mkdir /server
chown node:node /server

ufw default deny incoming
ufw allow ssh
ufw allow 80
ufw allow 443
ufw allow 8080
ufw allow 10331
ufw allow 10332
ufw allow 20331
ufw allow 20332
ufw enable
ufw status

Enable automatic updates:

vim /etc/apt/apt.conf.d/10periodic

Update to match:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

Install fail2ban and neo-python dependencies

apt-get install -y fail2ban
apt-get install python3.6 python3.6-dev python3.6-venv python3-pip libleveldb-dev libssl-dev g++

Change to user 'node' and setup neo-python

sudo su - node
cd /server
git clone https://github.com/CityOfZion/neo-python.git
cd neo-python

# Install the dependencies:
python3.6 -m venv venv
source venv/bin/activate
pip install -U setuptools pip wheel
pip install -e .

Now bootstrap the MainNet chain and notification databases:

python bootstrap.py -m
python bootstrap.py -m -n

Now you can start the api server manually like this:

/server/neo-python/venv/bin/python /server/neo-python/api-server.py -m --port-rpc 10332 --port-rest 8080

To use systemd as supervisor, you can use this config file: pyapi.service

Probably you'd want to setup nginx as reverse proxy, and setup SSL encrypted endpoints as well, either with Cloudflare and/or Let's Encrypt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment