diff --git a/package-lock.json b/package-lock.json index 7c78125..f0d636b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8677,9 +8677,9 @@ } }, "ipfs-coord": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-3.0.9.tgz", - "integrity": "sha512-EP1wo8vskjcXoDAr+YQuXT8ZYmw85UF91/bHL6mbu+sIvwmIrP/7ie6WmWD+XxX9FL19h6udevOvW/TCFyIx+w==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-3.2.0.tgz", + "integrity": "sha512-OmAhpoHTmQUxFhR5Z6Cl5SnN/2PrHLD+OtGR6ffyIowMzFeCK9/cmj/0FSOLAtNBEOg0vi4F6lc3HM82cnbhnw==", "requires": { "bch-encrypt-lib": "^2.0.0", "orbit-db": "^0.26.1" diff --git a/package.json b/package.json index 398116c..574f0cd 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "bcryptjs": "^2.4.3", "glob": "^7.1.6", "ipfs": "^0.54.4", - "ipfs-coord": "^3.0.9", + "ipfs-coord": "^3.2.0", "jsonrpc-lite": "^2.2.0", "jsonwebtoken": "^8.5.1", "kcors": "^2.2.2", diff --git a/src/lib/ipfs.js b/src/lib/ipfs.js index 45608ad..3b87836 100644 --- a/src/lib/ipfs.js +++ b/src/lib/ipfs.js @@ -31,13 +31,24 @@ class IPFSLib { // This is a 'macro' start method. It kicks off several smaller methods that // start the various subcomponents of this IPFS library. async start () { - await this.startIpfs() - await this.startIpfsCoord() + try { + await this.startIpfs() + await this.startIpfsCoord() - // Update the RPC instance with the instance of ipfs-coord. - this.rpc.ipfsCoord = this.ipfsCoord + // Update the RPC instance with the instance of ipfs-coord. + this.rpc.ipfsCoord = this.ipfsCoord - console.log('IPFS is ready.') + console.log('IPFS is ready.') + } catch (err) { + console.error('Error trying to start IPFS: ', err) + + // Added the exit() call because this app has been observed crashing due + // to out-of-memory errors. IPFS is a memory hog. It then can't automatically + // restart due to an IPFS lock-file error. Exiting the app will give a + // process management like pm2 or systemd to successfully restart the app. + console.log('Shutting down app. Hopefully pm2 can restart it!') + process.exit(1) + } } async startIpfs () { @@ -70,7 +81,9 @@ class IPFSLib { await this.ipfs.config.profiles.apply('server') const nodeConfig = await this.ipfs.config.getAll() - console.log(`IPFS node configuration: ${JSON.stringify(nodeConfig, null, 2)}`) + console.log( + `IPFS node configuration: ${JSON.stringify(nodeConfig, null, 2)}` + ) } catch (err) { console.error('Error in startIpfs()') throw err