Farmerbot is a service that farmers can run allowing them to automatically manage power of the nodes of their farm.
⚠️ Be careful: Make sure to run one farmerbot for each farm, otherwise the relay connection will close in all instances.
⚠️ Be careful: The timezone of the farmerbot will be the same as the time zone of the machine the farmerbot running inside.
-
add your configurations
-
Download farmerbot binaries.
-
Run the bot
farmerbot run -c config.yml -m <mnemonic> -n dev -d
- OR (create env file)
farmerbot run -c config.yml -e .env -d
Where:
Flags:
-c, --config string your config file that includes your farm, node and power configs. Available format is yml/yaml
--continue-power-on-error when set, the farmerbot will run even if there was an error powering on some of the nodes
-h, --help help for run
Global Flags:
-d, --debug by setting this flag the farmerbot will print debug logs too
-e, --env string enter your env file that includes your NETWORK and MNEMONIC_OR_SEED
-m, --mnemonic string the mnemonic of the account of the farmer
-n, --network string the grid network to use, available networks: dev, qa, test, and main (default "main")
-s, --seed string the hex seed of the account of the farmer
-k, --key-type string key type for mnemonic (default "sr25519")
Note: you should only provide
mnemonic
orseed
Note: If you provided
env
flag, you shouldn't provideseed
,key-type
,mnemonic
, ornetwork
flags
- Download the binaries from releases
- Extract the downloaded files
- Move the binary to any of
$PATH
directories, for example:
mv farmerbot /usr/local/bin
- Create a new
.env
file and add your farmer environment variables:
NETWORK="the grid network to use (default is mainnet)"
MNEMONIC_OR_SEED="your farm mnemonic or seed"
KEY_TYPE="your key type [ed25519, sr25519], default is sr25519"
-
Add your configurations
-
build
docker build -t farmerbot -f Dockerfile ../
- run (mount
.env
andconfig.yml
from your current directory to the container using-v
)
docker run -v $(pwd)/config.yml:/config.yml -v $(pwd)/.env:/.env farmerbot run -e /.env -c /config.yml -d
Run the following command inside the directory:
make build
- Create a new yml/yaml file
config.yml
and add your configurations:
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>"
priority_nodes:
- "<your node ID to have a priority in nodes management, 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>"
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>"
wake_up_threshold:
cru: "<the threshold number for cru usage that will need another node to be on, default is 80, optional>"
mru: "<the threshold number for mru usage that will need another node to be on, default is 80, optional>"
sru: "<the threshold number for sru usage that will need another node to be on, default is 80, optional>"
hru: "<the threshold number for hru usage that will need another node to be on, default is 80, optional>"
start
: to start (power on) a node
farmerbot start --node <node ID> -m <mnemonic> -n dev -d
Where:
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
farmerbot start all --farm <farm ID> -m <mnemonic> -n dev -d
Where:
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
farmerbot version
Calls can be send to the farmerbot via RMB. This section describes the arguments that they accept.
This call allows you to look for a node with specific requirements (minimum amount of resources, public config, etc). You will get the node id as a result. The farmerbot will power on the node if the node is off. It will also claim the required resources for 30 minutes. After that, if the user has not deployed anything on the node the resources will be freed and the node might go down again if it was put on by that call.
Arguments (all arguments are optional):
- has_gpus => if you require one or more gpus you can filter on that with this parameter (should be a positive value)
- gpu_vendors => a list of strings that will be used to filter the nodes on gpu vendor (for example AMD)
- gpu_devices => a list of strings that will be used to filter the nodes on gpu device (for example GTX 1080)
- certified => whether or not you want a certified node (not adding this argument means you don't care whether you get a certified or non certified node)
- public_config => whether or not you want a node with a public config (not adding this argument means you don't care whether or not the node has a public config)
- public_ips => how much public ips you need
- dedicated => whether you want a dedicated node (rent the full node)
- node_exclude => the list of node ids you want to exclude in your search
- hru => the amount of hru required in gigabytes
- sru => the amount of sru required in gigabytes
- mru => the amount of mru required in gigabytes
- cru => the amount of cru required
Result:
node_id
=> the node id that meets your requirements
Example:
This call is only allowed to be executed if it comes from the farmer (the twin ID should equal the farmer's twin ID). It will power on the node specified in the arguments. After powering on a node it will be
Arguments:
- node_id => the node id of the node that needs to powered on
Example:
This call is only allowed to be executed if it comes from the farmer (the twin ID should equal the farmer's twin ID). It will power off the node specified in the arguments. After powering off a node it will be
Arguments:
- node_id => the node id of the node that needs to powered off
Example:
This call is only allowed to be executed if it comes from the farmer (the twin ID should equal the farmer's twin ID). It will include an excluded node from power on and off calls (it should be included in the farmerbot configurations)
Arguments:
- node_id => the node id of the node that needs to be included
Example:
This call returns the current version of the farmerbot
Example:
This call returns the current report of nodes of the farmerbot
Result: a list of node reports, each node report includes:
id
=> the node idstate
=> the power state of the node (ON, OFF, Waking up, Shutting down)rented
=> if the node is rented (has an active rent contract) [true, false]dedicated
=> if the node is dedicated (its farm is dedicated or it has a dedicated node price) [true, false]public_config
=> if the node has public configurations [true, false]used
=> if the node is used (has used resources) [true, false]random_wakeups
=> times of the random wake ups for the node per monthsince_power_state_changed
=> the duration since last time power state of the node has changedsince_last_time_awake
=> the duration since last time the node state was onuntil_claimed_resources_timeout
=> the duration until claimed resources of the node timeout
Example:
Check the examples
To run examples:
- Don't forget to write your mnemonic in the example
cd <example>
go run main.go
Run the following command inside the directory:
make test