-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[update] run ipfs daemon in stellar-runtime
- spawn `jsipfs daemon` as child_process - signal 11 failure when run jsipfs node as nwjs-0.48.1 nodejs context - jsipfs module does not expose http-api server launcher - http-api server implementation(src/http) for jsipfs command only - NOTE: cannot access localhost with IpfsHttpClient from nwjs - unknown reason
- Loading branch information
Showing
10 changed files
with
1,145 additions
and
1,383 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# added for this project | ||
repo-*/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
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,22 @@ | ||
//This code is not used for stellar-runtime | ||
//NOTE: js-ipfs-0.50.1 has Http Api code, | ||
// but is not exposed except `jsipfs` command (src/cli/bin.js,daemon.js). | ||
|
||
const Ipfs = require("ipfs"); | ||
|
||
let node; | ||
exports.start = async (repo = "./repo-ipfs") => { | ||
//NOTE: ipfs config is in repo/config file | ||
if (!node) node = await Ipfs.create({ | ||
repo, relay: {enabled: true, hop: {enabled: true, active: true}}, | ||
}); | ||
const version = (await node.version()).version; | ||
const id = (await node.id()).id; | ||
console.debug(`IPFS version: ${version}`); | ||
console.debug(`Peer ID: ${id}`); | ||
//console.debug(`Peer ID: ${JSON.stringify(await node.id())}`); | ||
return {version, id}; | ||
}; | ||
exports.stop = () => { | ||
if (node) node.stop(); | ||
}; |
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,11 @@ | ||
const ipfs = require("./ipfs.cjs"); | ||
process.on("SIGHUP", () => { | ||
ipfs.stop(); | ||
}); | ||
(async () => { | ||
const repo = process.argv[2]; | ||
const info = await ipfs.start(repo); | ||
try { | ||
process.send(`${JSON.stringify(info)}`); | ||
} catch (err) {} | ||
})(); |
File renamed without changes.
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,35 @@ | ||
const {spawn} = require("child_process"); | ||
const IpfsHttpClient = require("ipfs-http-client"); | ||
|
||
let proc = null; | ||
exports.start = repo => new Promise((f, r) => { | ||
console.log(repo); | ||
if (!repo) return; | ||
//proc = spawn("npx", ["jsipfs", "daemon"], { | ||
proc = spawn("node", ["./node_modules/.bin/jsipfs", "daemon"], { | ||
env: Object.assign({"IPFS_PATH": repo}, process.env), | ||
stdio: [0, 1, 2], | ||
}); | ||
waitHttpApi().then(f, r); | ||
}); | ||
|
||
const waitHttpApi = async () => { | ||
const node = IpfsHttpClient("http://127.0.0.1:5002"); | ||
for (let i = 0; i < 10; i++) { | ||
try { | ||
const id = (await node.id()).id; | ||
const version = (await node.version()).version; | ||
return {id, version}; | ||
} catch (err) { | ||
await new Promise(f => setTimeout(f, 1000)); | ||
} | ||
} | ||
throw Error(); | ||
}; | ||
|
||
exports.stop = () => { | ||
if (proc) { | ||
proc.kill(`SIGHUP`); | ||
proc = null; | ||
} | ||
}; |
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.