Merge pull request #798 from shocknet/fixies
fix db date + fix zombie sub process
This commit is contained in:
commit
c3a617c961
11 changed files with 46 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -23,5 +23,6 @@ admin.connect
|
|||
debug.txt
|
||||
proto/autogenerated/debug.txt
|
||||
metrics_cache/
|
||||
metric_cache/
|
||||
metrics_events/
|
||||
bundler_events/
|
||||
|
|
@ -38,4 +38,4 @@ export default new DataSource({
|
|||
UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment, LspOrder, LndNodeInfo, TrackedProvider, InviteToken, DebitAccess, UserOffer],
|
||||
// synchronize: true,
|
||||
})
|
||||
//npx typeorm migration:generate ./src/services/storage/migrations/user_offer -d ./datasource.js
|
||||
//npx typeorm migration:generate ./src/services/storage/migrations/ops_time -d ./datasource.js
|
||||
|
|
@ -15,4 +15,4 @@ export default new DataSource({
|
|||
migrations: [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825]
|
||||
});
|
||||
|
||||
//npx typeorm migration:generate ./src/services/storage/migrations/root_ops -d ./metricsDatasource.js
|
||||
//npx typeorm migration:generate ./src/services/storage/migrations/root_ops_time -d ./metricsDatasource.js
|
||||
|
|
@ -348,7 +348,7 @@ export default class Handler {
|
|||
open_channels: openChannels.map(c => ({ channel_point: c.channelPoint, active: c.active, capacity: Number(c.capacity), channel_id: c.chanId, lifetime: Number(c.lifetime), local_balance: Number(c.localBalance), remote_balance: Number(c.remoteBalance), label: c.peerAlias })),
|
||||
forwarding_events: totalEvents,
|
||||
forwarding_fees: totalFees,
|
||||
root_ops: rootOps.map(r => ({ amount: r.operation_amount, created_at_unix: r.created_at.getTime(), op_id: r.operation_identifier, op_type: mapRootOpType(r.operation_type) })),
|
||||
root_ops: rootOps.map(r => ({ amount: r.operation_amount, created_at_unix: r.at_unix || 0, op_id: r.operation_identifier, op_type: mapRootOpType(r.operation_type) })),
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const send = (message: ChildProcessResponse) => {
|
|||
if (process.send) {
|
||||
process.send(message, undefined, undefined, err => {
|
||||
if (err) {
|
||||
getLogger({ component: "nostrMiddleware" })(ERROR, "failed to send message to parent process", err, "message:", message)
|
||||
getLogger({ component: "nostrMiddleware" })(ERROR, "failed to send message to parent process from nostr handler", err, "message:", message)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -493,8 +493,14 @@ class StorageProcessor {
|
|||
}
|
||||
|
||||
private sendResponse(response: OperationResponse<any>) {
|
||||
if (process.send) {
|
||||
process.send(response);
|
||||
try {
|
||||
|
||||
if (process.send) {
|
||||
process.send(response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("failed to send response to main process from storage processor, killing sub process")
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ export class RootOperation {
|
|||
@Column()
|
||||
operation_identifier: string
|
||||
|
||||
@Column({ default: 0 })
|
||||
at_unix: number
|
||||
|
||||
@CreateDateColumn()
|
||||
created_at: Date
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ export default class {
|
|||
}
|
||||
|
||||
async AddRootOperation(opType: string, id: string, amount: number, txId?: string) {
|
||||
return this.dbs.CreateAndSave<RootOperation>('RootOperation', { operation_type: opType, operation_amount: amount, operation_identifier: id }, txId)
|
||||
return this.dbs.CreateAndSave<RootOperation>('RootOperation', { operation_type: opType, operation_amount: amount, operation_identifier: id, at_unix: Math.floor(Date.now() / 1000) }, txId)
|
||||
}
|
||||
|
||||
async GetRootOperations({ from, to }: { from?: number, to?: number }, txId?: string) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class RootOpsTime1745428134124 implements MigrationInterface {
|
||||
name = 'RootOpsTime1745428134124'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE "temporary_root_operation" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "operation_type" varchar NOT NULL, "operation_amount" integer NOT NULL, "operation_identifier" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "at_unix" integer NOT NULL DEFAULT (0))`);
|
||||
await queryRunner.query(`INSERT INTO "temporary_root_operation"("serial_id", "operation_type", "operation_amount", "operation_identifier", "created_at", "updated_at") SELECT "serial_id", "operation_type", "operation_amount", "operation_identifier", "created_at", "updated_at" FROM "root_operation"`);
|
||||
await queryRunner.query(`DROP TABLE "root_operation"`);
|
||||
await queryRunner.query(`ALTER TABLE "temporary_root_operation" RENAME TO "root_operation"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "root_operation" RENAME TO "temporary_root_operation"`);
|
||||
await queryRunner.query(`CREATE TABLE "root_operation" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "operation_type" varchar NOT NULL, "operation_amount" integer NOT NULL, "operation_identifier" varchar NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
||||
await queryRunner.query(`INSERT INTO "root_operation"("serial_id", "operation_type", "operation_amount", "operation_identifier", "created_at", "updated_at") SELECT "serial_id", "operation_type", "operation_amount", "operation_identifier", "created_at", "updated_at" FROM "temporary_root_operation"`);
|
||||
await queryRunner.query(`DROP TABLE "temporary_root_operation"`);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,8 +15,9 @@ import { DebitToPub1727105758354 } from './1727105758354-debit_to_pub.js'
|
|||
import { UserCbUrl1727112281043 } from './1727112281043-user_cb_url.js'
|
||||
import { RootOps1732566440447 } from './1732566440447-root_ops.js'
|
||||
import { UserOffer1733502626042 } from './1733502626042-user_offer.js'
|
||||
import { RootOpsTime1745428134124 } from './1745428134124-root_ops_time.js'
|
||||
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042]
|
||||
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825, RootOps1732566440447]
|
||||
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825, RootOps1732566440447, RootOpsTime1745428134124]
|
||||
/* export const TypeOrmMigrationRunner = async (log: PubLogger, storageManager: Storage, settings: DbSettings, arg: string | undefined): Promise<boolean> => {
|
||||
await connectAndMigrate(log, storageManager, allMigrations, allMetricsMigrations)
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -356,8 +356,13 @@ class TlvFilesStorageProcessor {
|
|||
}
|
||||
|
||||
private sendResponse<T>(response: TlvOperationResponse<T>) {
|
||||
if (process.send) {
|
||||
process.send(response);
|
||||
try {
|
||||
if (process.send) {
|
||||
process.send(response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("failed to send response to main process from tlv files storage processor, killing sub process")
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue