Skip to content

Commit

Permalink
feat: check DIMSE is setup or not
Browse files Browse the repository at this point in the history
- Use port to check DIMSE is setup or not
- But have side effect that the port may not be used by DIMSE
  • Loading branch information
Chinlinlee committed May 5, 2023
1 parent 636e64f commit bb30a34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class DicomDimseConfig {
}
}

getPort() {
let bindArgIndex = this.dcm4cheQrscpArgv.findIndex(v => v === "-b");
/** @type {string} */
let bindInfo = this.dcm4cheQrscpArgv[bindArgIndex + 1];
return bindInfo.split(":").pop();
}

}

class FhirConfig {
Expand Down
13 changes: 12 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,18 @@ if (osPlatform.includes("linux")) {
if (raccoonConfig.dicomDimseConfig.enableDimse) {
const { java } = require("./models/DICOM/dcm4che/java-instance");
let dcmQrScpClass = await java.importClassAsync("org.dcm4che3.tool.dcmqrscp.DcmQRSCP");
await dcmQrScpClass.main(raccoonConfig.dicomDimseConfig.dcm4cheQrscpArgv);
const net = require("net");
let checkPortServer = net.createServer()
.once("listening", async function () {
checkPortServer.close();
await dcmQrScpClass.main(raccoonConfig.dicomDimseConfig.dcm4cheQrscpArgv);
})
.once("error", function(err) {
if(err.code === "EADDRINUSE") {
console.log("QRSCP's port is already in use, please check is QRSCP running or another app running");
}
})
.listen(raccoonConfig.dicomDimseConfig.getPort());
}
})();

Expand Down

0 comments on commit bb30a34

Please sign in to comment.