Hopefully you’ve read Part 1 of this series of articles and already have your public node up and running. If not, we highly suggest you head over there and give it a read before continuing with this article.
Note: To make sure that you’ve read this document before proceeding, you won’t be able to copy and paste any of the commands.
Running a public node that the community can use can be challenging at times. 100% uptime is great but that’s not always possible in some environments. Running a public node takes work. Despite our best efforts right now, we can’t just Set it and Forget it.
We can; however, use some cool tools developed by the community to help make it easier to maintain a public node. We’ll take a look at how to do this below.
TurtleCoind High Availability Daemon Wrapper
This project is designed to wrap the TurtleCoind daemon on a system and monitor it for hangups, locks, fork, or other events that cause the daemon to stop responding to requests in an accurate manner.
The wrapper does its best to keep TurtleCoind running in tip top shape and always responding to requests from your users. Follow the directions below to set it up on your system. We’ve included instructions below designed to work on a your favorite flavour of *nix variants.
You’re going to need a newer version of Node to get things started. Use of any of the older v0.x releases hasn’t been supported for a while so don’t even bother trying to use those. If you are not sure what version of Node.js is installed on your system (if at all), simple run the below command:
Hopefully you’ll see something relatively modern come back like version 8:
If not, head on over to Installing Node.js via package manager for instructions on how to install the latest version for your distro.
Once you’ve completed that step and have verified you are running an up-to-date copy, we’ll continue on below.
Setting up PM2
Setting it up from here is pretty easy going forward. We’ll start by installing PM2: Advanced, production process manager for Node.js to help keep our node script running 24/7/365 and persist across system reboots.
To do so, we’ll run the following commands:
If everything completes successfully, we’ll have the PM2 process up and running and ready to run our script.
Setting up the Wrapper
turtlecoind-ha package is registered with NPM, so installation is pretty easy. We’ll create a new directory for our process to live in and install it there.
After a few moments, the package will download and install with all the needed dependencies. As long as the installation finishes with the line(s) like those below you are good to proceed.
Next, we’re going to create a new file in our folder named
turtlenode.js and dump the code below into that file. We’ve linked to the raw code here.
Most of the code above is designed for spitting us understand what’s going on with our node at any given time. For education purposes, we’re going to leave that intact.
We want to pay attention to the section above that initializes the node parameters.
You’ll need to change those values to match the TurtleCoin address you’re using to collect your node convenience charges as well as the amount of that fee. Remember, as stated in Part 1 of this series, the fee amount is expressed in shells or “atomic units” not TRTL.
Once we’ve made the necessary changes, we’ll save that file and we’re almost ready to rock and roll.
Prepping the Node
For maximum ease of setup you’ll need to copy the latest version of
TurtleCoind for your system into the directory we created above. You can compile your own, or download the latest release binaries from the TurtleCoin GitHub repository.
We also advise that you download the latest checkpoints from the Offical Repo to help your node sync up as quickly as possible. The following command will make this quick and easy for you.
Testing the Node
Now that we have all of that set up and ready to rock and roll, we’ll test our node to make sure everything is set up correctly.
Run the following command to find out if everything will start up correctly.
If all goes well, you’ll see output like this:
Depending on if you’ve ever synced a daemon on this machine – it could take a while. Don’t fret if that’s the case. We can continue with even an unsyncronized daemon.
As long as we see TurtleCoind has started followed by TurtleCoind is attempting to synchronize with the network… we know that we’ve set up our environment correctly. Press
CTRL-C to stop the node from running. We’re ready to hand off control to PM2.
Launching the Node
Handing off control to PM2 is pretty simple. To do so enter the following command(s):
Checking the Node
To verify that the node is running, we can issue the following command:
PM2 will spit back a list of processes maintained by the software such as:
To view our node logs, issue the command:
Once your node is synced, you’ll start to see log entries such as:
Now sit back, relax, and let people know about your public node.