npm i -g @geut/permanent-seeder
Alternatively you can git clone
this repo and build it from source:
# install deps
npm i
npm run bootstrap
# build the dashboard
cd packages/dashboard
cp .env.example .env
npm run build
# start the seeder
cd ../cli
./bin/run stop
./bin/run start
First, create a base config file, you can tweak it later ;-)
$ permanent-seeder config:init
Then, start the Permanent Seeder daemon
$ permanent-seeder start
:rocket:
$ permanent-seeder [COMMAND] [--OPTIONS]
$ permanent-seeder config:[init|get]
init
: creates the base config file for the Permanent Seeder. This is a .toml
file that will live in ~/permanent-seeder/settings.toml
.get
: returns the settings from the CLI. Useful when you are changing values and want to be sure they are pick up by the Permanent Seeder.Default settings:
## Permanent seeder path (will be completed on config:init)
path = 'permanent-seeder'
## Enable stats recording
save_stats = true
## [optional] Preferred swarm port
# swarm_port =
## [optional] Api service settings
# [api]
# port = 3001
## [optional] HTTPS certificate and key
# [api.https]
# cert = "/path/to/cert.crt"
# key = "/path/to/cert.key"
## keys.endpoints = array of configs per endpoint
[[keys.endpoints]]
# Where to fetch keys
url = 'http://localhost:3000'
# Frequency between fetchs (in minutes)
frequency = 5
# Hook to parse response
hook = 'endpoint-hook.js'
## [optional] To add another endpoint, uncomment and complete next lines:
# [[keys.endpoints]]
# url =
# frequency =
# hook
$ permanent-seeder start
Bootstrap a Permanent Seeder instance that will keep up running in the background. If you change settings, you will need to call start
command again.
$ permanent-seeder status
It will return instance status. If it is running and some basic stats.
$ permanent-seeder stop
Stops the current instance.
$ permanent-seeder dashboard
Opens the dashboard app in a browser. If you want to manually access the dashboard, it can be found in: localhost:3001
:warning: Note: The dashboard app runs in http://localhost:3001
. If you deploy the Permanent Seeder on a server and wants to access the dashboard from the outside, you may need to setup a reverse proxy.
We use the .env.example
file as a placeholder for some environment variables that we use internally, like PUBLIC_URL
.
If you build the Permanent Seeder from source then you may want to customize some things.
There are two variables that can be used:
PUBLIC_URL
: used to define the root path of the dashboard app. DEFAULT = '/'REACT_APP_API_VERSION
: used to indicate the api version to use. DEFAULT = 'v1'For development there are a few others variables that you can tweak, like the SOCKET_URL
and API_URL
. Checkout the full .env.example
:
REACT_APP_API_VERSION=v1
PUBLIC_URL=/
## Extend eslint config
EXTEND_ESLINT=true
## Optional ENVs only for development
#REACT_APP_SOCKET_URL=
#REACT_APP_API_URL=
$ permanent-seeder key:[add|remove|remove-all]
add
: Insert a new key Permanent Seeder db, it will start downloading and seeding ASAP.remove
: Removes a single key from the seeder db and also stops seeding it (e.g.: no more announcing to other peers)remove-all
: Removes and unnanounce all the keys in the db.$ permanent-seeder logs --[live|all|error]
live
: like doing a tail -f
of the logs.all
: Show all the logs stored.error
: Display only error logs.$ permanent-seeder repl
Useful to inspect the Permanent Seeder under the hood. :microscope:
The Permanent Seeder can fetch
keys from an external endpoint, i.e: perform a GET
request against a particular endpoint. This can be useful if you maintain a service that stores hyperdrive's keys. If that is the case, then the Permament Seeder can fetch those keys regularly. You can think of this like a cron job.
Whilst, we internally expect an Array<{url}>
, you can customize and parse the fetch response the way you need it.
To do this, you will need to modify $HOME/permanent-seeder/endpoint-hook.js
.
That hook will be called after fetch
the response.
You can also tweak the fetch frequency
(defined in minutes) and the endpoint url
. These options can be found in the settings.toml
file:
[[keys.endpoints]]
url = "http://localhost:3000"
frequency = 5
hook = "$HOME/permanent-seeder/endpoint-hook.js"
The Permanent Seeder also allows for another endpoint, this one for deleted keys. With this action the Permanent Seeder can fetch an array of keys similarly to what we defined previously for the keys endpoint (adding).
The setting looks like this:
[[keys.remove]]
url = "http://localhost:60620/deletes.json"
hook = "/Users/deka/permanent-seeder/endpoint-hook.js"
Again, we internally expect an Array<{url}>
, but you can customize and parse the fetch response the way you need it.
To do this, you can tweak the hook response. By default the "delete keys endpoint" is using the same default hook used with the keys endpoint.
Finally, the fetch frequency is managed by the keys endpoint frequency. In other words, they run with the same frequency interval.
Here are some rules that we follow to know when to update the keys.
Actions that result in update:
Actions that does not result in update:
The Permanent Seeder is a CLI tool that can starts a daemon which will seed hyperdrive's keys that you pass into it. Using the CLI you can add, remove keys, check the status and inspect logs.
It also contains a dashboard
that you can use to have a visual reference of what is going on with your hyperdrives.
As you can see the project does a couple of things. To do this we decided to use a microservices based approach. We choose to use moleculer as the structural framework behind the Permanent Seeder. This enables multiples processes to communicate each other and at the same time each of these will have a single responsibility/scope. This also give us some room to scale things up if needed. :sunglasses:
Below we define some internal API routes that can be used to obtain some information about the PS running instance as well as some basic drive queries.
GET /api/<API_VERSION>/drives/:key
Returns summary data associated to a specific drive key
. Data may contain download information, peers info, seeding status and basic index.json
information and version.
GET /api/<API_VERSION>/drives/:key/size
Returns only the download information.
GET /api/<API_VERSION>/drives/:key/peers
Returns only the peers information.
GET /api/<API_VERSION>/drives/:key/stats
Returns only information about the drive's files and its download status.
GET /api/<API_VERSION>/drives/:key/info
Returns only the index.json
information part.
GET /api/<API_VERSION>/drives/:key/seedingStatus
Returns only the seeding status label.
GET /api/<API_VERSION>/drives/:key/files/:file
Download the file passed as argument from key
drive.
GET /api/v1/stats/host
Returns information about the host. CPU load, memory and directory usage.
GET /api/v1/stats/network
Returns network information. Include things like online status, swarm information (hole-punching, bootstrapping info and network address), along with transferred bytes.
GET /api/<API_VERSION>/raw/:key
Returns the raw data associated with the seeded drive (key
). The returned data may include various lifecycle events with their timestamps. This endpoint will return values as long as save_stats
config property is enabled. See config.
You can also query data using the drive version.
GET /api/<API_VERSION>/drives/:key/versions
Returns all the versions saved for key
drive
GET /api/<API_VERSION>/drives/:key/:version/info
Returns only the info
field for this specific key and version
GET /api/<API_VERSION>/drives/:key/:version/stats
Returns only the stats
(files) field for this specific key and version
GET /api/<API_VERSION>/drives/:key/:version/files/:file
Download the file passed as argument from a specific drive's checkout (key
+version
).
For releasing new versions we are using GitHub Actions :rocket: This is the process.
git co -b username/release-${newVersion}
npm run release
It will prompt you what is the next version.Release: newVersion
:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.
:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.
:clap: Many thanks to @nicomanso for offering some basic infrastructure that was used for early testing and @krahser for his outstanding docker contribution (PR)
MIT © A GEUT project