@tableland/local
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -102,9 +102,8 @@ "use strict"; | ||
await this.shutdownRegistry(); | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
} | ||
catch (err) { | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
throw new Error(`unexpected error during shutdown: ${err.message}`); | ||
} | ||
finally { | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
} | ||
} | ||
@@ -144,2 +143,3 @@ async shutdownRegistry() { | ||
this.validator.shutdown(); | ||
this.validator.cleanup(); | ||
}); | ||
@@ -269,3 +269,3 @@ } | ||
// quits the parent local-tableland process | ||
this.validator.cleanup(); | ||
this.validator.cleanup(this.validatorDir); | ||
// shouldFork and chainId are optional, and the validator.start method | ||
@@ -272,0 +272,0 @@ // handles parsing them and filling in with defaults |
@@ -102,9 +102,8 @@ "use strict"; | ||
await this.shutdownRegistry(); | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
} | ||
catch (err) { | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
throw new Error(`unexpected error during shutdown: ${err.message}`); | ||
} | ||
finally { | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
} | ||
} | ||
@@ -144,2 +143,3 @@ async shutdownRegistry() { | ||
this.validator.shutdown(); | ||
this.validator.cleanup(); | ||
}); | ||
@@ -269,3 +269,3 @@ } | ||
// quits the parent local-tableland process | ||
this.validator.cleanup(); | ||
this.validator.cleanup(this.validatorDir); | ||
// shouldFork and chainId are optional, and the validator.start method | ||
@@ -272,0 +272,0 @@ // handles parsing them and filling in with defaults |
@@ -18,3 +18,3 @@ /// <reference types="node" /> | ||
shutdown(): void; | ||
cleanup(): void; | ||
cleanup(validatorDir?: string): void; | ||
} | ||
@@ -21,0 +21,0 @@ declare class ValidatorDev { |
@@ -112,10 +112,27 @@ "use strict"; | ||
// fully nuke the database and reset the config file | ||
cleanup() { | ||
cleanup(validatorDir) { | ||
// we allow passing an optional directory to clean in case the user wants | ||
// to cleanup before starting | ||
if (typeof validatorDir !== "string") { | ||
validatorDir = this.validatorDir; | ||
} | ||
// if there's no directory we can't cleanup | ||
if (!validatorDir || validatorDir.trim() === "") | ||
return; | ||
shelljs_1.default.rm("-rf", (0, node_path_1.resolve)(this.validatorDir, "backups")); | ||
const dbFiles = [ | ||
(0, node_path_1.resolve)(this.validatorDir, "database.db"), | ||
(0, node_path_1.resolve)(this.validatorDir, "database.db-shm"), | ||
(0, node_path_1.resolve)(this.validatorDir, "database.db-wal"), | ||
(0, node_path_1.resolve)(this.validatorDir, "metrics.db"), | ||
(0, node_path_1.resolve)(this.validatorDir, "metrics.db-shm"), | ||
(0, node_path_1.resolve)(this.validatorDir, "metrics.db-wal"), | ||
]; | ||
for (const filepath of dbFiles) { | ||
shelljs_1.default.rm("-f", filepath); | ||
try { | ||
shelljs_1.default.rm("-f", filepath); | ||
} | ||
catch (err) { | ||
console.log("validator cleanup:", err); | ||
} | ||
} | ||
@@ -122,0 +139,0 @@ // reset the Validator config file in case it was modified with a custom |
@@ -91,9 +91,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
await this.shutdownRegistry(); | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
} | ||
catch (err) { | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
throw new Error(`unexpected error during shutdown: ${err.message}`); | ||
} | ||
finally { | ||
__classPrivateFieldGet(this, _LocalTableland_instances, "m", _LocalTableland__cleanup).call(this); | ||
} | ||
} | ||
@@ -133,2 +132,3 @@ async shutdownRegistry() { | ||
this.validator.shutdown(); | ||
this.validator.cleanup(); | ||
}); | ||
@@ -257,3 +257,3 @@ } | ||
// quits the parent local-tableland process | ||
this.validator.cleanup(); | ||
this.validator.cleanup(this.validatorDir); | ||
// shouldFork and chainId are optional, and the validator.start method | ||
@@ -260,0 +260,0 @@ // handles parsing them and filling in with defaults |
@@ -18,3 +18,3 @@ /// <reference types="node" /> | ||
shutdown(): void; | ||
cleanup(): void; | ||
cleanup(validatorDir?: string): void; | ||
} | ||
@@ -21,0 +21,0 @@ declare class ValidatorDev { |
@@ -106,10 +106,27 @@ import { join, resolve } from "node:path"; | ||
// fully nuke the database and reset the config file | ||
cleanup() { | ||
cleanup(validatorDir) { | ||
// we allow passing an optional directory to clean in case the user wants | ||
// to cleanup before starting | ||
if (typeof validatorDir !== "string") { | ||
validatorDir = this.validatorDir; | ||
} | ||
// if there's no directory we can't cleanup | ||
if (!validatorDir || validatorDir.trim() === "") | ||
return; | ||
shell.rm("-rf", resolve(this.validatorDir, "backups")); | ||
const dbFiles = [ | ||
resolve(this.validatorDir, "database.db"), | ||
resolve(this.validatorDir, "database.db-shm"), | ||
resolve(this.validatorDir, "database.db-wal"), | ||
resolve(this.validatorDir, "metrics.db"), | ||
resolve(this.validatorDir, "metrics.db-shm"), | ||
resolve(this.validatorDir, "metrics.db-wal"), | ||
]; | ||
for (const filepath of dbFiles) { | ||
shell.rm("-f", filepath); | ||
try { | ||
shell.rm("-f", filepath); | ||
} | ||
catch (err) { | ||
console.log("validator cleanup:", err); | ||
} | ||
} | ||
@@ -116,0 +133,0 @@ // reset the Validator config file in case it was modified with a custom |
{ | ||
"name": "@tableland/local", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "Tooling to start a sandboxed Tableland network.", | ||
@@ -77,3 +77,3 @@ "repository": { | ||
}, | ||
"gitHead": "4af3f4f7deecc094eba8049c0c907fbc240b475d" | ||
"gitHead": "9245c0dc426579db5b4813df4ee202bcc79aca7c" | ||
} |
@@ -280,3 +280,3 @@ /** | ||
// quits the parent local-tableland process | ||
this.validator.cleanup(); | ||
this.validator.cleanup(this.validatorDir); | ||
// shouldFork and chainId are optional, and the validator.start method | ||
@@ -355,8 +355,9 @@ // handles parsing them and filling in with defaults | ||
await this.shutdownRegistry(); | ||
this.#_cleanup(); | ||
} catch (err: any) { | ||
this.#_cleanup(); | ||
throw new Error( | ||
`unexpected error during shutdown: ${err.message as string}` | ||
); | ||
} finally { | ||
this.#_cleanup(); | ||
} | ||
@@ -399,2 +400,3 @@ } | ||
this.validator.shutdown(); | ||
this.validator.cleanup(); | ||
}); | ||
@@ -401,0 +403,0 @@ } |
@@ -131,3 +131,12 @@ import { type ChildProcess } from "node:child_process"; | ||
// fully nuke the database and reset the config file | ||
cleanup(): void { | ||
cleanup(validatorDir?: string): void { | ||
// we allow passing an optional directory to clean in case the user wants | ||
// to cleanup before starting | ||
if (typeof validatorDir !== "string") { | ||
validatorDir = this.validatorDir; | ||
} | ||
// if there's no directory we can't cleanup | ||
if (!validatorDir || validatorDir.trim() === "") return; | ||
shell.rm("-rf", resolve(this.validatorDir, "backups")); | ||
@@ -137,6 +146,15 @@ | ||
resolve(this.validatorDir, "database.db"), | ||
resolve(this.validatorDir, "database.db-shm"), | ||
resolve(this.validatorDir, "database.db-wal"), | ||
resolve(this.validatorDir, "metrics.db"), | ||
resolve(this.validatorDir, "metrics.db-shm"), | ||
resolve(this.validatorDir, "metrics.db-wal"), | ||
]; | ||
for (const filepath of dbFiles) { | ||
shell.rm("-f", filepath); | ||
try { | ||
shell.rm("-f", filepath); | ||
} catch (err) { | ||
console.log("validator cleanup:", err); | ||
} | ||
} | ||
@@ -143,0 +161,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
891512
19874