Skip to content

Commit

Permalink
#126 #74 - attempt v0.11.4
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoluis-pdm committed Nov 15, 2022
1 parent eaed537 commit 035d6d8
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pdm-web-components/docs
blockchain-node
/apihub-root/external-volume/mq_*

privatesky
/privatesky
themes

!ionic-core/dist
Expand Down
4 changes: 2 additions & 2 deletions apihub-root/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ <h3><a id="participant-name">Participant</a> Workspace</h3>

<p><span style="font-weight: bold;">WARNING:</span> Unstable software and environments. Use at your own risk! Data persistence at risk of unexpected reset!</p>

<h2>v0.11.3 Release Notes 2022-11-15</h2>
<h2>v0.11.4 Release Notes 2022-11-15</h2>
<ul>
<li>Decentralized Brick Storage (Each participant's data is stored on their own servers), with centralised BDNS (Blockchain Domain Naming Service) for distributed brick storage configuration <a href="https://github.com/PharmaLedger-IMI/fgt-workspace/issues/123">#123</a>.
The running environment now has an additional pre-startup script <code>npm run update-docker-apihub-config</code>, that needs 2 additional environment variables:
Expand Down Expand Up @@ -837,7 +837,7 @@ <h2>Release notes 2021-03-26</h2>
<br>
This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 853992
<br>&nbsp;<br>
v<!-- VERSION_START -->0.11.3-gb1499506<!-- VERSION_END --> &copy;&nbsp;2021 <a href="http://pharmaledger.eu">Pharmaledger.eu</a> - All Rights Reserved.
v<!-- VERSION_START -->0.11.3-geaed537a<!-- VERSION_END --> &copy;&nbsp;2021 <a href="http://pharmaledger.eu">Pharmaledger.eu</a> - All Rights Reserved.
</footer>

<script type="application/javascript">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const PING = "PING";
const PONG = "PONG";

module.exports.fork = function pingPongFork(modulePath, args, options){
const child_process = require("child_process");
const defaultStdio = ["inherit", "inherit", "inherit", "ipc"];

if(!options){
options = {stdio: defaultStdio};
}else{
if(typeof options.stdio === "undefined"){
options.stdio = defaultStdio;
}

let stdio = options.stdio;
if(stdio.length<3){
for(let i=stdio.length; i<4; i++){
stdio.push("inherit");
}
stdio.push("ipc");
}
}

let child = child_process.fork(modulePath, args, options);

child.on("message", (message)=>{
if(message === PING){
child.send(PONG);
}
});

return child;
};

module.exports.enableLifeLine = function(timeout){

if(typeof process.send === "undefined"){
console.log("\"process.send\" not found. LifeLine mechanism disabled!");
return;
}

let lastConfirmationTime;
const interval = timeout || 10 * 60 * 1000;

// this is needed because new Date().getTime() has reduced precision to mitigate timer based attacks
// for more information see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
const roundingError = 101;

function sendPing(){
try {
process.send(PING);
} catch (e) {
//console.log('Parent is not available, shutting down');
//exit(1)
}
}

process.on("message", function (message){
if(message === PONG){
lastConfirmationTime = new Date().getTime();
}
});

function exit(code){
setTimeout(()=>{
process.exit(code);
}, 0);
}

const exceptionEvents = ["SIGINT", "SIGUSR1", "SIGUSR2", "SIGTERM", "SIGHUP"];
let killingSignal = false;
for(let i=0; i<exceptionEvents.length; i++){
process.on(exceptionEvents[i], (event, code)=>{
killingSignal = true;
clearInterval(timeoutInterval);
//console.log(`Caught event type [${exceptionEvents[i]}]. Shutting down...`, code, event);
//exit(code);
});
}

const timeoutInterval = setInterval(function(){
const currentTime = new Date().getTime();

if(typeof lastConfirmationTime === "undefined" || currentTime - lastConfirmationTime < interval + roundingError && !killingSignal){
sendPing();
}else{
//console.log("Parent process did not answer. Shutting down...", process.argv, killingSignal);
//exit(1);
}
}, interval);
};
1 change: 1 addition & 0 deletions docker/api/traceability/startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# This script expects cwd to be /fgt-workspace
rm -rf apihub-root/external-volume/config
cp -r docker/api/traceability/config apihub-root/external-volume/config
cp -r blockchain-patch/apply/privatesky/psknode/core/utils/pingpongFork.js privatesky/psknode/core/utils/pingpongFork.js
npm run switch-to-simul-chain ; npm run server & ( sleep 5s ; npm run build-all; npm run build-dsu-explorer ; tail -f /dev/null )
2 changes: 1 addition & 1 deletion octopus-freeze.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "smartClone",
"target": ".",
"collectLog": false,
"commit": "2f1d49f168cdad784008a610b4c48cea311b755c"
"commit": "be8027202d04032bed93fb8de74253d61ec6a3b9"
},
{
"type": "execute",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fgt-workspace",
"version": "0.11.3",
"version": "0.11.4",
"description": "",
"scripts": {
"dev-install": "node ./bin/mkDevEnv.js && npm install",
Expand Down

0 comments on commit 035d6d8

Please sign in to comment.