sManager (Storage Manager) is a file picking bot which continuously picking and handling files from Crust Network. Node operators can customize this module to implement their own file handling strategy. sManager maintains a local database to help making decision on pulling files.
The local database stores below information:
- File Records: The files metadata(tips, size, replicas count, expire time etc.) on Crust Network.
- File and Owner Relationship: sManager also maintains the relationship between a file and an on-chain account. This information will help making better pulling decision.
- Chain Metadata: e.g. the block and time on chain.
- Pin Records: The pin history of files.
- Cleanup Records: The files needs to removed from local filesystem, normally this is triggered when a file expires on Crust Network.
Checkout Db Schema for the schema details.
sManager was designed to have serveral tasks running independently. Tasks are either scheduled by the block event or by configured intervals. Each task plays as an actor which consumes/produces some information and communicate with other tasks through the db or applicaion context.
sManager follows the Fails Early priciple which means it will shutdown on any unexpected error. To support this priciple, tasks are designed to be recoverable after application restarts.
Below are a list of components that sManager has implemented.
Indexers extract information into the local database from various data sources. Currently sManager has implemented below indexers:
- Chain Database Indexer: indexes file records from the Crust Network on-chain database.
- Chain Event Indexer: indexes file records by listening latest chain event.
- Chain Time Indexer: a simple indexer which push the latest block height and it's timestamp to the config table.
Simple tasks are speciualized tasks which runs periodly. Currently sManager has implemented below tasks:
- Group Info Updater: Update sworker identity information from sworker api.
- Ipfs Gc: Schedule ipfs gc periodly.
- Telemetry Reporting: Report smanager statistics information to the telemetry server.
- Pull Scheduler: Schedule file pulling based on configured strategey.
- Seal Status Updater: Update sealing status periodly.
- File Retry Task: Retry pulling if possible.
- File Cleanup Task: Cleanup deleted files from local filesystem.
- Clone repo
git clone https://github.com/crustio/crust-smanager.git
- Installing
It's recommended to use
volta
as the node version manager. Please follow the volta docs to install it.
cd crust-smanager && npm i
- Debug
npm run dev
- Run in Prod
npm run build
npm start
It's recommended to run sManager using Docker with the restart=always
restart policy.
A daemon guard should be configured if you want to run sManager natively without docker. Tools like pm2
and nodemon
could be used.
Checkout smanager-config.example.json
Those config items will be configured in the sManager configuration setup process. The meaning of each item is as follows:
-
chain.account: your member account
-
chain.endPoint: your chain endpoint
-
sworker.endPoint: your sWorker endpoint
-
ipfs.endPoint: your IPFS endpoint
-
dataDir: the directory of the database of sManager
-
scheduler.minSrdRatio: a minimum ratio of SRD that one node can start to accept storage orders.
For example, if the ratio is 30, then your node will start to accept storage order once the ratio of SRD capacity is higher than 30%
-
scheduler.strategy.dbFilesWeight: how much bandwidth of this node will be used to fetch and store the history storage orders(Storage orders in the past four months).
-
scheduler.strategy.newFilesWeight: how much bandwidth of this node will be used to fetch and store the newest storage orders.