-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4988 from Joystream/colossus-beta
colossus pruning service
- Loading branch information
Showing
17 changed files
with
666 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Command, flags } from '@oclif/command' | ||
import stringify from 'fast-safe-stringify' | ||
import logger from '../../services/logger' | ||
import { QueryNodeApi } from '../../services/queryNode/api' | ||
import { performCleanup } from '../../services/sync/cleanupService' | ||
|
||
/** | ||
* CLI command: | ||
* Prunes outdated data objects: removes all the local stored data objects that the operator is no longer obliged to store. | ||
* storage. | ||
* | ||
* @remarks | ||
* Should be run only during the development. | ||
* Shell command: "dev:cleanup" | ||
*/ | ||
export default class DevCleanup extends Command { | ||
static description = `Runs the data objects cleanup/pruning workflow. It removes all the local stored data objects that the operator is no longer obliged to store` | ||
|
||
static flags = { | ||
help: flags.help({ char: 'h' }), | ||
workerId: flags.integer({ | ||
char: 'w', | ||
required: true, | ||
description: 'Storage node operator worker ID.', | ||
}), | ||
bucketId: flags.integer({ | ||
char: 'b', | ||
required: true, | ||
description: 'The buckerId to sync prune/cleanup', | ||
}), | ||
cleanupWorkersNumber: flags.integer({ | ||
char: 'p', | ||
required: false, | ||
description: 'Cleanup/Pruning workers number (max async operations in progress).', | ||
default: 20, | ||
}), | ||
queryNodeEndpoint: flags.string({ | ||
char: 'q', | ||
required: false, | ||
default: 'http://localhost:8081/graphql', | ||
description: 'Query node endpoint (e.g.: http://some.com:8081/graphql)', | ||
}), | ||
uploads: flags.string({ | ||
char: 'd', | ||
required: true, | ||
description: 'Data uploading directory (absolute path).', | ||
}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const { flags } = this.parse(DevCleanup) | ||
const bucketId = flags.bucketId.toString() | ||
const qnApi = new QueryNodeApi(flags.queryNodeEndpoint) | ||
logger.info('Cleanup...') | ||
|
||
try { | ||
await performCleanup(flags.workerId, [bucketId], flags.cleanupWorkersNumber, qnApi, flags.uploads) | ||
} catch (err) { | ||
logger.error(err) | ||
logger.error(stringify(err)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.