Skip to content

Commit a70f7fa

Browse files
committed
Add stop hook to IPFS service
1 parent 7d78310 commit a70f7fa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/ipfs.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Injectable, Inject } from '@nestjs/common';
1+
import { Injectable, Inject, OnApplicationShutdown } from '@nestjs/common';
22
import * as IPFS from 'ipfs';
33
import { IPFS_MODULE_OPTIONS } from './ipfs.constants';
44
import { IPFSModuleOptions } from './interfaces';
55

66
@Injectable()
7-
export class IpfsService {
7+
export class IpfsService implements OnApplicationShutdown {
88
// DEBUG: Give IPFS Node a type when implemented
99
private _ipfsNode: any;
1010

@@ -15,4 +15,8 @@ export class IpfsService {
1515
? this._ipfsNode
1616
: (this._ipfsNode = await IPFS.create(this._ipfsOptions));
1717
}
18+
19+
async onApplicationShutdown(): Promise<void> {
20+
await this._ipfsNode && this._ipfsNode.stop();
21+
}
1822
}

0 commit comments

Comments
 (0)