[User Guide] Automatic Docker Container Controller! 👨🏼‍💻

Welcome to the Node Controller :man_technologist:t3:

Run multiple nodes on one server?
Having issues with RAM or CPU usage?

Use this script to automatically start and stop your nodes based on how close to COMMITTEE they are. The following script will check each node via the Node Monitor API (monitor.incognito.org) and handle starting and stopping for you.

Getting Started

:star: Download the node_controller.sh script to your server.

sudo wget https://raw.githubusercontent.com/lukemax47/node_controller/main/node_controller.sh

:star: Edit the node_keys list with all of your Public Validator Keys (same keys used on monitor.incognito.org)

sudo nano node_controller.sh

:star: Adjust the epoch triggers (optional) - Currently set to turn on <5 epochs

if [ "$epoch" -gt 11 ] - epochs over # to shut off container

elif [ "$epoch" -lt 10 ] - epochs under # to turn on container

:star: Make the script executable

sudo chmod +x node_controller.sh

:star: Add this script to your crontab to automatically run
(Example: 0 */2 * * * /home/server/node_controller.sh)

sudo crontab -e

That’s it! :rocket:

Your nodes will now automatically start and stop with no interaction on your part. Feel free to leave any comments, questions, suggestions, etc in the comments below.

Changelog:

Version 1.1 - 2/8/2024 -

  • Increased readability of output with color and region defined areas.
  • Added verbose output for better debugging.

Version 1.0 - 8/23/2023 -

  • Inital release with working auto start and stop functionality.
  • User adjustable variables to start containers under 10 epochs and stop after 11.
5 Likes

Thanks @Jared for sharing this script . Very handy indeed. However , does this mean when the node is stopped , when it is restarted it will take some time to sync with the blockchain. This in its own right will cause extra load on the CPU, right?

Just trying to figure out what the trade offs are before I implement this script.

Yes, the nodes will start syncing with the network again from where they were at, when they were turned off.

For my setup, turning the node back on under 10 epochs seems to give plenty of time to sync to Latest.

Hi Jared,
It’s a great script, thanks!

May it be improved by adding also something to save space on disk like this one does? The author said that he doesn’t maintain the code anymore.

Hello @GGolov,

My scripts work best with that users size reduction script.

The developer of that script didn’t say they were stopping development but instead they would no longer assist user requests and individual support. They update it quite often and I use it daily.

1 Like

Yes but he also said he isn’t making it for the community anymore but his own uses. It is designed to do things differently now and you can use it if you know whY to do, but for most regular users like me, you need to be on his older code for it to work right.

1 Like

Understood, I’ll add this to my list of scripts to potentially put together.

Eventually, I plan to combine them all together into one main script to control and automate everything.

1 Like

Thanks, this script, combined with the size reduction one, lets me easily keep up 3 vNodes on a small VPS on Contabo (with the storage upgrade). No problem so far.

1 Like

Awesome! Glad to hear it. :partying_face:

Hey Jared,

It seems it would be beneficial to not have the docker containers autostart at boot but instead just have this script run at boot. How would I accomplish that?

Sure, on my server I have this script run every 2 hours so it can start and stop containers automagically. You can do so with the following:

1 Like

Thanks Jared. I already have that but I’d also want it to run at boot and disable the automatic docker container startup at boot so the script handles everything related to starting/stopping the containers.

You can use:

@reboot /path/to/your/script.sh

to automatically run the script on boot.

IncognitoUpdater.service is used to keep the nodes online and also automatically update them to newer tags. You can use sudo systemctl stop IncognitoUpdater.service. After that you’ll need to remove and/or change the name of the service:

/etc/systemd/system/IncognitoUpdater.service
Example: /etc/systemd/system/IncognitoUpdater.service.backup

Hey everyone,

I just released version 1.1. This version includes:

  • Increased readability of output with color and region defined areas.
  • Added verbose output for better debugging.

Thank you @brico84 for reaching out to me on Telegram. Hopefully everyone can benefit from this new version.

I’m hard at work on a toolkit that will have this script and many others combined into one convenient script. :man_technologist:

1 Like