manual transfer done for documentation, still hero issues for parsing

This commit is contained in:
2024-04-15 21:57:46 +00:00
parent 99c05100c3
commit b63f091e63
536 changed files with 20490 additions and 0 deletions

View File

@@ -0,0 +1,436 @@
<h1> Farmerbot Additional Information </h1>
<h2> Table of Contents </h2>
- [Introduction](#introduction)
- [Additional Information](#additional-information)
- [General Considerations](#general-considerations)
- [YAML Configuration File Template](#yaml-configuration-file-template)
- [Supported Commands and Flags](#supported-commands-and-flags)
- [Minimum specs to run the Farmerbot](#minimum-specs-to-run-the-farmerbot)
- [How to Prepare Your Farm for the Farmerbot with WOL](#how-to-prepare-your-farm-for-the-farmerbot-with-wol)
- [WOL Requirements](#wol-requirements)
- [Enabling WOL in the BIOS](#enabling-wol-in-the-bios)
- [ZOS Nodes and NIC](#zos-nodes-and-nic)
- [NIC Firmware and WOL](#nic-firmware-and-wol)
- [How to Move Your Farm to a Different Network](#how-to-move-your-farm-to-a-different-network)
- [The differences between power "state" and power "target"](#the-differences-between-power-state-and-power-target)
- [The differences between uptime, status and power state](#the-differences-between-uptime-status-and-power-state)
- [The sequence of events for a node managed by the Farmerbot](#the-sequence-of-events-for-a-node-managed-by-the-farmerbot)
- [The problematic states of a 3node set with the Farmerbot](#the-problematic-states-of-a-3node-set-with-the-farmerbot)
- [Using the ThreeFold Node Status Bot](#using-the-threefold-node-status-bot)
- [CPU overprovisioning](#cpu-overprovisioning)
- [Seed phrase and HEX secret](#seed-phrase-and-hex-secret)
- [Farmerbot directory tree](#farmerbot-directory-tree)
- [Dedicated Nodes and the Farmerbot](#dedicated-nodes-and-the-farmerbot)
- [Periodic wakeup](#periodic-wakeup)
- [Time period between random wakeups and power target update](#time-period-between-random-wakeups-and-power-target-update)
- [Upgrade to the new Farmerbot](#upgrade-to-the-new-farmerbot)
- [Set the Farmerbot without the mnemonics of a ThreeFold Dashboard account](#set-the-farmerbot-without-the-mnemonics-of-a-threefold-dashboard-account)
- [Maintenance](#maintenance)
- [See the power state and power target of 3Nodes](#see-the-power-state-and-power-target-of-3nodes)
- [With GraphQL](#with-graphql)
- [With Grid Proxy](#with-grid-proxy)
- [Change manually the power target of a 3Node](#change-manually-the-power-target-of-a-3node)
- [Properly reboot the node if power target "Down" doesn't work](#properly-reboot-the-node-if-power-target-down-doesnt-work)
- [Add a 3Node to a running Farmerbot](#add-a-3node-to-a-running-farmerbot)
- [Update the Farmerbot with a new release](#update-the-farmerbot-with-a-new-release)
- [Questions and Feedback](#questions-and-feedback)
***
# Introduction
We present some general information concerning the Farmerbot as well as some advice for proper maintenance and troubleshooting.
# Additional Information
We present additional information to complement the [Quick Guide](farmerbot_quick.md).
## General Considerations
The Farmerbot doesnt have to run physically in the farm since it instructs nodes over RMB to power on and off. The Farmerbot should be running at all time.
The Farmerbot uses the nodes in the farm to send WOL packets to the node that needs to wakeup. For this reason, you need at least one node per farm to be powered on at all time. If you do not specify one node to be always on, the Farmerbot will randomly choose a node to stay on for each cycle. If all nodes in a subnet are powered off, there is no way other nodes in other subnets will be able to power them on again.
Note that if you run the Farmerbot on your farm, it is logical to set the node running the Farmerbot as always on. In this case, it will always be this node that wakes up the other nodes.
Currently, you can run only one Farmerbot per farm. Since you can only deploy one Farmerbot per farm, the Farmerbot can only run on one node at a time.
Since you need at least one node to power up a second node, you can't use the Farmerbot with just one node. You need at least two 3Nodes in your farm to correctly use the Farmerbot.
The Farmerbot gets its data completely from TFChain. This means that, unlike the previous version, the Farmerbot will not start all the nodes when it restarts.
## YAML Configuration File Template
The quick guide showed a simple form of the YAML configuration file. Here are all the parameters that can be set for the configuration file.
```
farm_id: "<your farm ID, required>"
included_nodes: [optional, if no nodes are added then the farmerbot will include all nodes in the farm, farm should contain at least 2 nodes]
- "<your node ID to be included, required at least 2>"
excluded_nodes:
- "<your node ID to be excluded, optional>"
never_shutdown_nodes:
- "<your node ID to be never shutdown, optional>"
power:
periodic_wake_up_start: "<daily time to wake up nodes for your farm, default is the time your run the command, format is 00:00AM or 00:00PM, optional>"
wake_up_threshold: "<the threshold number for resources usage that will need another node to be on, default is 80, optional>"
periodic_wake_up_limit: "<the number (limit) of nodes to be waken up everyday, default is 1, optional>"
overprovision_cpu: "<how much node allows over provisioning the CPU , default is 1, range: [1;4], optional>"
```
## Supported Commands and Flags
We present the different commands for the Farmerbot.
- `start`: to start (power on) a node
```bash
farmerbot start --node <node ID> -m <mnemonic> -n dev -d
```
Where:
```bash
Flags:
--node uint32 the node ID you want to use
Global Flags:
-d, --debug by setting this flag the farmerbot will print debug logs too
-m, --mnemonic string the mnemonic of the account of the farmer
-n, --network string the grid network to use (default "main")
-s, --seed string the hex seed of the account of the farmer
-k, --key-type string key type for mnemonic (default "sr25519")
```
- `start all`: to start (power on) all nodes in a farm
```bash
farmerbot start all --farm <farm ID> -m <mnemonic> -n dev -d
```
Where:
```bash
Flags:
--farm uint32 the farm ID you want to start your nodes ins
Global Flags:
-d, --debug by setting this flag the farmerbot will print debug logs too
-m, --mnemonic string the mnemonic of the account of the farmer
-n, --network string the grid network to use (default "main")
-s, --seed string the hex seed of the account of the farmer
-k, --key-type string key type for mnemonic (default "sr25519")
```
- `version`: to get the current version of farmerbot
```bash
farmerbot version
```
## Minimum specs to run the Farmerbot
The Farmerbot can run on any computer/server, it could even run on a laptop, so to speak. As long as it has an internet connection, the Farmerbot will be working fine.
The Farmerbot runs fine on a VM with a single vcore and 2GB of RAM. For the storage, you need to have room for Docker and its dependencies. Thus 1 or 2GB of free storage, with the OS already installed, should be sufficient.
## How to Prepare Your Farm for the Farmerbot with WOL
ZOS can utilize 2 NIC's (Network Interface Card) of a node (server, workstation, desktop, ..). The first NIC on the motherboard will always be what we call the ZOS/dmz NIC, the second one is used for public config's (Gateway, public IP's for workloads, ..). So if you don't have public IP's in your farm, only the first NIC of your ZOS node will be used. This subnet is where the farmerbot operates. If you do have public IP's the same applies.
Wake On LAN (WOL) is used to be able to boot (start) a ZOS node remotely that was shut down by the farmerbot. It works by sending what is called a 'magic packet' to the NIC MAC address of a ZOS node. If that NIC is setup correctly, aka 'listening' for the packet, the node will start up, post and boot ZOS. The farmerbot will keep a list of MAC addresses for nodes under it's management, so it knows where to send the packet if it's required.
## WOL Requirements
WOL comes with a few requirements. We list them in the sections that follow.
### Enabling WOL in the BIOS
Enable WOL in the BIOS of your ZOS node.
A ZOS node must be capable of doing WOL. Have a look at your node hardware / BIOS manual. If so make sure to enable it in the BIOS! A bit of research will quickly tell you how to enable for your hardware. Some older motherboards do not support this, sometimes you can be lucky it does after a BIOS upgrade, but that is brand/model specific.
Some examples:
![farmerbot_bios_1|517x291](img/farmerbot_bios_1.jpeg)
![farmerbot_bios_2|499x375](img/farmerbot_bios_2.jpeg)
### ZOS Nodes and NIC
All your ZOS nodes and their first NIC (ZOS/dmz) should be in the same network subnet (also called network segment or broadcast domain).
This requires some basic network knowledge. WOL packets can not be send across different subnets by default, it can but this requires specific configuration on the firewall that connects the two subnets. Though cross-subnet WOL is currently not supported by the farmerbot.
A 'magic' WOL packet is sent only on networking layer 2 (L2 or the 'data link layer') based on MAC address. So not on L3 based on ip address. This is why all nodes that should be brought up via WOL, need to be in the same subnet.
You can check if this is the case like this: if for example one node has the ip 192.168.0.20/24, then all other nodes should have an ip between 192.168.0.1 and 192.168.0.254. You can calculate subnet ranges easely here: https://www.tunnelsup.com/subnet-calculator/
So for the 192.168.0.0/24 example, you can see the range under 'Usable Host Range':
![farmerbot_bios_3|499x500](img/farmerbot_bios_3.png)
### NIC Firmware and WOL
Some NIC's require WOL to be set on the NIC firmware.
This is fully handled by ZOS. Every time ZOS boots it will enable WOL on links if they require it. So if a ZOS node then is added to a farmerbot, it will have WOL enabled on its NIC when it's turned off (by the farmerbot).
Your farmerbot can be run on any system, including on a node. It doesn't have to be on the same network subnet as the nodes from the farm. The nodes of the farm on the other hand have to be in the same LAN. Don't hesitate to ask your technical questions here, we and the community will help you set things up!
## How to Move Your Farm to a Different Network
Note that the Farmerbot is currently available for Dev Net, QA Net, Test Net and Main Net. Thus, it might not be necessary to move your farm to a different network.
To move your farm to a different network, you need to create a new bootstrap image for the new network instead of your current network. You should also wipe your 3Nodes' disks before moving to a different network.
To download the Zero-OS bootstrap image, go to the usual bootstrap link [https://v3.bootstrap.grid.tf/](https://v3.bootstrap.grid.tf/) and select the network you want.
![test_net|690x422](img/farmerbot_5.png)
Once you have your new bootstrap image for the new network, [wipe your disks](../3node_building/4_wipe_all_disks.md), insert the new bootstrap image and reboot the 3Node.
## The differences between power "state" and power "target"
The target is what is set by the Farmerbot or can be set by the farmer manually on TF Chain. Power state can only be set by the node itself, in response to power targets it observes on chain.
## The differences between uptime, status and power state
There are three distinctly named endpoints or fields that exist in the back end systems:
* Uptime
* number of seconds the node was up, as of it's last uptime report. This is the same on GraphQL and Grid Proxy.
* Status
* this is a field that only exists on the Grid Proxy, which corresponds to whether the node sent an uptime report within the last 40 minutes.
* Power state
* this is a field that only exists on GraphQL, and it's the self reported power state of the node. This only goes to "down" if the node shut itself down at request of the Farmerbot.
## The sequence of events for a node managed by the Farmerbot
The sequence of events for a node managed by farmerbot should look like this:
1. Node is online. Target, state, and status are all "Up".
2. Farmerbot sets node's target to "Down".
3. Node sets its state to "Down" and then shuts off.
4. Three hours later the status switches to "Down" because the node hasn't been updated.
5. At periodic wake up time, Farmerbot sets node's target to "Up".
6. Node receives WoL packet and starts booting.
7. After boot is complete, node sets its state to "Up" and also submits uptime report.
8. updatedAt is updated with time that uptime report was received and status changes to "Up".
At that point the cycle is completed and will repeat.
## The problematic states of a 3node set with the Farmerbot
These are problematic states:
1. Target is set to "Up" but state and status are "Down" for longer than normal boot time (node isn't responding).
2. Target has been set to "Down" for longer than ~23.5 hours (farmerbot isn't working properly).
3. Target is "Down" but state and status are up (Zos is potentially not responding to power target correctly).
4. State is "Up" but status is "Down" (node shutdown unexpectedly).
## Using the ThreeFold Node Status Bot
You can use the [ThreeFold Node Status Bot](https://t.me/tfnodestatusbot) to see the nodes' status in relation to the Farmerbot.
## CPU overprovisioning
In the context of the ThreeFold grid, overprovisioning a CPU means that you can allocate more than one deployment to one CPU.
In relation to the Farmerbot, you can set a value between 1 and 4 of how much the CPU can be overprovisioned. For example, a value of 2 means that the Farmerbot can allocate up to 2 deployments to one CPU.
## Seed phrase and HEX secret
When setting up the Farmerbot, you will need to enter either the seed phrase or the HEX secret of your farm. For farms created in the TF Connect app, the HEX secret from the app is correct. For farms created in the TF Dashboard, you'll need the seed phrase provided when you created the account.
## Farmerbot directory tree
As a general template, the directory tree of the Farmerbot will look like this:
```
└── farmerbot_directory
├── .env
└── conf.yml
```
## Dedicated Nodes and the Farmerbot
Dedicated nodes are managed like any other node. Nodes marked as dedicated can only be rented completely. Whenever a user wants to rent a dedicated node the user sends a find_node job to the farmerbot. The farmerbot will find such a node, power it on if it is down and reserve the full node (for 30 minutes). The user can then proceed with creating a rent contract for that node. The farmerbot will get that information and keep that node powered on. It will no longer return that node as a possible node in future find_node jobs. Whenever the rent contract is canceled the farmerbot will notice this and shutdown the node if the resource usage allows it.
## Periodic wakeup
The minimum period between two nodes to be waken up is currently 5 minutes. This means that every 5 minutes a new node wakes up during the periodic wakeup.
Once all nodes are awaken, they all shut down at the same time, except the node that stays awaken to wake up the other during the next periodic wake.
## Time period between random wakeups and power target update
The time period between a random wakeup and the moment the power target is set to down is between 30 minutes and one hour.
Whenever a random wakeup is initiated, the Farmerbot will wait 30 minutes for the node to be up. Once the node is up, the Farmerbot will keep that node up for 30 minutes for the two following reasons:
* The node can send uptime report
* If the node was put online for a given user deployment, this time priod gives ample time for the user to deploy their workload.
This ensures an optimal user experience and reliablity in 3Nodes' reports.
Note that each node managed by the Farmerbot will randomly wakeup on average 10 times a month.
## Upgrade to the new Farmerbot
If you are still running the old version of the Farmerbot (written in V), you can easily upgrade to the new Farmerbot (written in Go). You simply need to properly stop the old Farmerbot and then follow the new [Farmerbot guide](./farmerbot_quick.md).
Here are the steps to properly stop the old Farmerbot.
* Go to the diretory with the old Farmerbot docker files and fully stop the old Farmerbot:
```
docker compose rm -f -s -v
```
* You should also make sure that there are no containers left from the previous runs. First, list all containers:
```
docker container ls --all
```
* Then delete the remaining containers:
```
docker container rm -f -v NAME_OF_CONTAINER
```
Once the old Farmerbot is properly stopped and deleted, follow the new [Farmerbot guide](./farmerbot_quick.md).
## Set the Farmerbot without the mnemonics of a ThreeFold Dashboard account
If you've lost the mnemonics associated with an account created on the ThreeFold Dashboard, it is still possible to set the Farmerbot with this account, but it's easier to simply create a new account and a new farm. Hopefully, the process is simple.
- Create a new account on the Dashboard. This will generate a new twin.
- Create a new farm and create new bootstrap images of your new farm.
- Reboot your nodes with the new bootstrap images. This will automatically migrate your nodes with their current node IDs to the new farm.
If you are using the Farmerbot, at this point, you will be able to set it with the mnemonics associated with the new farm.
# Maintenance
## See the power state and power target of 3Nodes
### With GraphQL
You can use [GraphQL](https://graphql.grid.tf/graphql) to see the power state and power target of 3Nodes.
To find all nodes within one farm, use the following line with the proper farm ID (here we set farm **1** as an example):
```
query MyQuery {
nodes(where: {farmID_eq: 1}) {
power {
target
state
}
nodeID
}
}
```
To find a specific node, write the following with the proper nodeID (here we set node **655** as an example):
```
query MyQuery {
nodes(where: {nodeID_eq: 655}) {
power {
state
}
nodeID
}
}
```
### With Grid Proxy
You can also see the power state and power target of a 3Node with Grid proxy.
Use the following URL while adjusting the proper node ID (here we set node **1** as an example):
```
https://gridproxy.grid.tf/nodes/1
```
Then, in the response, you will see the following:
```
"power": {
"state": "string",
"target": "string"
},
```
If the state and target are not defined, the string will be empty.
## Change manually the power target of a 3Node
You can use the Polkadot Extrinsics for this.
* Go to the Polkadot.js.org website's endpoint based on the network of your 3Node:
* [Main net](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftfchain.grid.tf#/extrinsics)
* [Test net](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftfchain.test.grid.tf#/extrinsics)
* [Dev net](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftfchain.dev.grid.tf#/extrinsics)
* [QA net](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Ftfchain.qa.grid.tf#/extrinsics)
* Make sure that **Developer -> Extrinsics** is selected
* Select your account
* Select **tfgridModule**
* Select **changepowertarget(nodeId,powerTarget)**
* Select the node you want to change the power target
* Select the power target (**Up** or **Down**)
* Click **Submit Transaction** at the bottom of the page
## Properly reboot the node if power target "Down" doesn't work
* Set the power target to "Down" manually
* Reboot the node and wait for it to set its power state to "Down"
* Once power target and state are both set to "Down", you can manually power off the node and reboot it
## Add a 3Node to a running Farmerbot
If the Farmerbot is running and you want to add a new 3Node to your farm, you can proceed as follows.
- Boot the new 3Node
- Once the node is registered to the grid, a new node ID will be generated
- If you set the section `included_nodes` in the YAML configuration file
- Add the new node ID to the configuration file
- Restart the Farmerbot with the systemd command `restart` (in this example, the service is called `farmerbot`)
```
systemctl restart farmerbot
```
## Update the Farmerbot with a new release
There are only a few steps needed to update the Farmerbot to a new release.
- Download the latest [ThreeFold tfgrid-sdk-go release](https://github.com/threefoldtech/tfgrid-sdk-go/releases) and extract the farmerbot for your specific setup (here we use `x86_64`). On the line `wget ...`, make sure to replace `<latest_release>` with the latest Farmerbot release.
```
wget https://github.com/threefoldtech/tfgrid-sdk-go/releases/download/<latest_release>/tfgrid-sdk-go_Linux_x86_64.tar.gz
tar xf tfgrid-sdk-go_Linux_x86_64.tar.gz farmerbot
```
- Make a copy of the old version in case you need it in the future:
```
mv /usr/local/bin/farmerbot /usr/local/bin/farmerbot_archive
```
- Move the new Farmerbot to the local bin
```
mv farmerbot /usr/local/bin
```
- Restart the bot
```
systemctl restart farmerbot
```
- Remove the tar file
```
rm tfgrid-sdk-go_Linux_x86_64.tar.gz
```
# Questions and Feedback
If you have questions concerning the Farmerbot, feel free to ask for help on the [ThreeFold Forum](https://forum.threefold.io/) or on the [ThreeFold Farmer chat](https://t.me/threefoldfarmers).

View File

@@ -0,0 +1,15 @@
<h1> Farmerbot </h2>
The Farmerbot is a service that farmers can run in order to automatically manage the nodes in their farms. The behavior of the farmerbot is customizable through a YAML configuration file.
We present here a quick guide to accompany farmers in setting up the Farmerbot. This guide contains the essential information to deploy the Farmerbot on the TFGrid. The other section contains additional information and details on the working of the Farmerbot.
For more information on the Farmerbot, you can visit the [Farmerbot repository](https://github.com/threefoldtech/tfgrid-sdk-go/tree/development/farmerbot) on Github. You can also consult the Farmerbot FAQ if needed.
<h2> Table of Contents </h2>
- [Quick Guide](./farmerbot_quick.md)
- [Additional Information](./farmerbot_information.md)
- [Minting and the Farmerbot](./farmerbot_minting.md)
> Note: The Farmerbot is an optional feature developed by ThreeFold. Please use at your own risk. While ThreeFold will do its best to fix any issues with the Farmerbot and minting, if minting is affected by the use of the Farmerbot, ThreeFold cannot be held responsible.

View File

@@ -0,0 +1,26 @@
<h1> Minting and the Farmerbot </h2>
<h2> Table of Contents </h2>
- [Introduction](#introduction)
- [Minting Rules](#minting-rules)
- [Disclaimer](#disclaimer)
***
## Introduction
We cover essential features of ThreeFold minting in relation with the Farmerbot.
## Minting Rules
There are certain minting rules that are very important when it comes to farming on the ThreeFold Grid while using the Farmerbot.
- The 3Node should wake up within 30 minutes of setting the power target to **Up**.
- If the 3Node does not respect this rule, the 3Node won't mint for the whole minting period.
- The 3Node must wake up at least once every 24 hours.
- If the 3Node does not respect this rule, the 3Node won't mint for a 24-hour period.
## Disclaimer
Please note that the Farmerbot is an optional feature developed by ThreeFold. Please use at your own risk. While ThreeFold will do its best to fix any issues with the Farmerbot and minting, if minting is affected by the use of the Farmerbot, ThreeFold cannot be held responsible.

View File

@@ -0,0 +1,292 @@
<h1> Farmerbot Quick Guide </h1>
<h2> Table of Contents </h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Farmerbot Costs on the TFGrid](#farmerbot-costs-on-the-tfgrid)
- [Enable Wake-On-Lan](#enable-wake-on-lan)
- [Deploy a Full VM](#deploy-a-full-vm)
- [Farmerbot Setup](#farmerbot-setup)
- [Download the Farmerbot Binaries](#download-the-farmerbot-binaries)
- [Create the Farmerbot Files](#create-the-farmerbot-files)
- [Run the Farmerbot](#run-the-farmerbot)
- [Set a systemd Service](#set-a-systemd-service)
- [Check the Farmerbot Logs](#check-the-farmerbot-logs)
- [Stop the Farmerbot](#stop-the-farmerbot)
- [Farmerbot Files](#farmerbot-files)
- [Configuration File Template (config.yml)](#configuration-file-template-configyml)
- [Environment Variables File Template (.env)](#environment-variables-file-template-env)
- [Running Multiple Farmerbots on the Same VM](#running-multiple-farmerbots-on-the-same-vm)
- [Questions and Feedback](#questions-and-feedback)
***
## Introduction
In this guide, we show how to deploy the [Farmerbot](https://github.com/threefoldtech/tfgrid-sdk-go/tree/development/farmerbot) on a full VM running on the TFGrid.
This guide can be done on bare metal or on a full VM running on the TFGrid. You need at least two 3Nodes on the same farm to make use of the Farmerbot.
This version of the Farmerbot also works with ARM64. This means that if you have a Pi 3, 4, or Zero 2 with a 64 bit OS, you can download the appropriate release archive and it will work properly.
Read the [Additional Information](farmerbot_information.md) section for further details concerning the Farmerbot.
## Prerequisites
- The TFChain account associated with the farm should have at least 5 TFT (recommended is 50 TFT)
## Farmerbot Costs on the TFGrid
If you run the Farmerbot on a 3Node on the TFGrid, you will have to pay TFT to deploy on that 3Node. You can run a full VM at minimum specs for the Farmerbot, that is 1vcore, 15GB of SSD storage and 512MB of RAM. Note that you can use the Planetary Network. You do not need to deploy a 3Node with IPv4. The cost on main net for this kind of workload is around 0.175TFT/hour (as of the date 11-07-23).
Next to that, you will have to pay the transaction fees every time the Farmerbot has to wake up or shut down a node. This means that you need some TFT on the account tied to the twin of your farm.
For the periodic wakeups, each node in the farm is shut down and powered on once a day, i.e. 30 times per month. Also, there is 10 random wakeups per month for each node. This means that each node is turned off and on 40 times per month in average. In that case, the average cost per month to power on nodes and shut them back down equals:
> average transaction fees cost per month = 0.001 TFT (extrinsic fee) * amount of nodes * 40 * 2 (1 for powering down, one for powering up)
## Enable Wake-On-Lan
For a 3Node to work properly with the Farmerbot, the parameter wake-on-lan must be enabled. Enabling wake-on-lan on your 3Node may differ depending on your computer model. Please refer to the documentation of your computer if needed.
Usually the feature will be called Wake-on-Lan and you need to set it as "enabled" in the BIOS/UEFI settings.
Here are some examples to guide you:
* Racker Server, Dell R720
* Go into `System Setup -> Device Settings -> NIC Port -> NIC Configuration`
* Set Wake-on-Lan to `Enable`
* Desktop Computer, HP EliteDesk G1
* Go to Power -> Hardware Power Management
* Disable `S5 Maximum Power Saving`
* Go to `Advanced -> Power-On Options`
* Set `Remote Wake up Boot source` to `Remote Server`
> Hint: Check the Z-OS monitor screen and make sure that all the 3Nodes are within the same lan (e.g. all 3Nodes addresses are between 192.168.15.00 and 192.168.15.255).
For more information on WOL, [read this section](farmerbot_information.md#how-to-prepare-your-farm-for-the-farmerbot-with-wol).
## Deploy a Full VM
For this guide, we run the Farmerbot on a Full VM running on the TFGrid. Note that while you do not need to run the Farmerbot on the TFGrid, the whole process is very simple as presented here.
- Deploy a full VM on the TFGrid
- Update and upgrade the VM
```
apt update && apt upgrade
```
- Reboot and reconnect to the VM
```
reboot
```
## Farmerbot Setup
We present the different steps to run the Farmerbot using the binaries.
> For a script that can help automate the steps in this guide, [check this forum post](https://forum.threefold.io/t/new-farmerbot-install-script/4207).
### Download the Farmerbot Binaries
- Download the latest [ThreeFold tfgrid-sdk-go release](https://github.com/threefoldtech/tfgrid-sdk-go/releases) and extract the farmerbot for your specific setup (here we use `x86_64`). On the line `wget ...`, make sure to replace `<latest_release>` with the latest Farmerbot release.
```
wget https://github.com/threefoldtech/tfgrid-sdk-go/releases/download/<latest_release>/tfgrid-sdk-go_Linux_x86_64.tar.gz
tar xf tfgrid-sdk-go_Linux_x86_64.tar.gz farmerbot
```
- Move the Farmerbot
```
mv farmerbot /usr/local/bin
```
- Remove the tar file
```
rm tfgrid-sdk-go_Linux_x86_64.tar.gz
```
### Create the Farmerbot Files
- Create Farmerbot files directory
```
cd ~
mkdir farmerbotfiles
```
- Create the Farmerbot `config.yml` file ([see template below](#configuration-file-template-configyml))
```
nano ~/farmerbotfiles/config.yml
```
- Create the environment variables file and set the variables ([see template below](#environment-variables-file-template-env))
```
nano ~/farmerbotfiles/.env
```
### Run the Farmerbot
We run the Farmerbot with the following command:
```
farmerbot run -e ~/farmerbotfiles/.env -c ~/farmerbotfiles/config.yml -d
```
For farmers with **ed25519** keys, the flag `-k` should be used. Note that by default, the Farmerbot uses the **sr25519** keys.
```
farmerbot run -k ed25519 -e ~/farmerbotfiles/.env -c ~/farmerbotfiles/config.yml -d
```
For more information on the supported commands, the [Additional Information section](farmerbot_information.md#supported-commands-and-flags). You can also consult the [Farmerbot repository](https://github.com/threefoldtech/tfgrid-sdk-go/tree/development/farmerbot).
Once you've verified that the Farmerbot runs properly, you can stop the Farmerbot and go to the next section to set a Farmerbot service. This step will ensure the Farmerbot keeps running after exiting the VM.
### Set a systemd Service
It is highly recommended to set a Ubuntu systemd service to keep the Farmerbot running after exiting the VM.
* Create the service file
* ```
nano /etc/systemd/system/farmerbot.service
```
* Set the Farmerbot systemd service
```
[Unit]
Description=ThreeFold Farmerbot
StartLimitIntervalSec=0
[Service]
Restart=always
RestartSec=5
StandardOutput=append:/root/farmerbotfiles/farmerbot.log
StandardError=append:/root/farmerbotfiles/farmerbot.log
ExecStart=/usr/local/bin/farmerbot run -e /root/farmerbotfiles/.env -c /root/farmerbotfiles/config.yml -d
[Install]
WantedBy=multi-user.target
```
* Enable the Farmerbot service
```
systemctl daemon-reload
systemctl enable farmerbot
systemctl start farmerbot
```
* Verify that the Farmerbot service is properly running
```
systemctl status farmerbot
```
### Check the Farmerbot Logs
Once you've set a Farmerbot systemd service [as show above](#set-a-systemd-service), the Farmerbot will start writing logs to the file `farmerbot.log` in the directory `farmerbotfiles`.
Thus, you can get more details on the operation of the Farmerbot by inspecting the log file. This can also be used to see the **Farmerbot Report Table** as this table is printed in the Farmerbot log.
* See all logs so far
```
cat ~/farmerbotfiles/farmerbot.log
```
* See the last ten lines and new logs as they are generated
```
tail -f ~/farmerbotfiles/farmerbot.log
```
* See all logs and new lines as they are generated
```
tail -f -n +1 ~/farmerbotfiles/farmerbot.log
```
* See the last report table
```
tac ~/farmerbotfiles/farmerbot.log | grep -B5000 -m1 "Nodes report" | tac
```
### Stop the Farmerbot
You can stop the farmerbot with the following command:
```
systemctl stop farmerbot
```
After stopping the farmerbot, any nodes in standby mode will remain in standby. To bring them online, use this command:
```
farmerbot start all -e /root/farmerbotfiles/.env --farm <farm_id>
```
## Farmerbot Files
### Configuration File Template (config.yml)
In this example, the farm ID is 1, we are setting the Farmerbot with 4 nodes and the node 1 never shuts down, we set a periodic wakeup at 1:00PM.
Note that the timezone of the farmerbot will be the same as the time zone of the machine the farmerbot running inside. By default, a full VM on the TFGrid will be set in UTC.
```
farm_id: 1
included_nodes:
- 1
- 2
- 3
- 4
never_shutdown_nodes:
- 1
power:
periodic_wake_up_start: 01:00PM
```
Note that if the user wants to include all the nodes within a farm, they can simply omit the `included_nodes` section. In this case, all nodes of the farm will be included in the Farmerbot, as shown in the example below:
```
farm_id: 1
never_shutdown_nodes:
- 1
power:
periodic_wake_up_start: 01:00PM
```
For more information on the configuration file, refer to the [Additional Information section](farmerbot_information.md#yaml-configuration-file-template).
You can also consult the [Farmerbot repository](https://github.com/threefoldtech/tfgrid-sdk-go/tree/development/farmerbot).
### Environment Variables File Template (.env)
The network can be either `main`, `tets`, `dev` or `qa`. The following example is with the main network.
```
MNEMONIC_OR_SEED="word1 word2 word3 ... word12"
NETWORK="main"
```
## Running Multiple Farmerbots on the Same VM
You can run multiple instances of the Farmerbot on the same VM.
To do so, you need to create a directory for each instance of the Farmerbot. Each directory should contain the configuration and variables files as shown above. Once you've set the files, you can simply execute the Farmerbot `run` command to start each bot in each directory.
It's recommended to use distinct names for the directories and the services to easily differentiate the multiple farmerbots running on the VM.
For example, the directory tree of two Farmerbots could be:
```
└── farmerbotfiles
   ├── farmerbot1
   │   ├── .env
   │   └── config.yml
   └── farmerbot2
   ├── .env
   └── config.yml
```
For example, the services of two Farmerbots could be named as follows:
```
farmerbot1.service
farmerbot2.service
```
## Questions and Feedback
This guide is meant to get you started quickly with the Farmerbot. That being said, there is a lot more that can be done with the Farmerbot.
For more information on the Farmerbot, please refer to the [Additional Information section](./farmerbot_information.md). You can also consult the [official Farmerbot Go repository](https://github.com/threefoldtech/tfgrid-sdk-go/tree/development/farmerbot).
If you have any questions, you can ask the ThreeFold community for help on the [ThreeFold Forum](https://forum.threefold.io/) or on the [ThreeFold Farmers Chat](https://t.me/threefoldfarmers) on Telegram.
> This is the new version of the Farmerbot written in Go. If you have any feedback and issues, please let us know!

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB