Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
close dnode socket instead of process.exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Hall committed Jan 11, 2017
1 parent c1de9da commit 2774fdf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bin/storjshare-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ sock.on('remote', function(rpc) {
rpc.destroy(storjshare_destroy.nodeid, (err) => {
if (err) {
console.error(`\n cannot destroy node, reason: ${err.message}`);
process.exit(1);
return sock.end();
}
console.info(`\n * share ${storjshare_destroy.nodeid} destroyed`);
process.exit(0);
sock.end();
});
});
9 changes: 7 additions & 2 deletions bin/storjshare-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ if (!storjshare_logs.nodeid) {

const sock = dnode.connect(config.daemonRpcPort);

process.on('exit', () => {
sock.end();
process.exit(0);
});

sock.on('remote', function(rpc) {
rpc.status((err, shares) => {
if (err) {
console.error(`\n cannot get status, reason: ${err.message}`);
process.exit(1);
return sock.end();
}

let logFilePath = null;
Expand All @@ -41,7 +46,7 @@ sock.on('remote', function(rpc) {

if (!utils.existsSync(logFilePath)) {
console.error(`\n no logs to show for ${storjshare_logs.nodeid}`);
process.exit(0);
return sock.end();
}

let logTail = new Tail(logFilePath);
Expand Down
4 changes: 2 additions & 2 deletions bin/storjshare-restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ sock.on('remote', function(rpc) {
rpc.restart(storjshare_restart.nodeid, (err) => {
if (err) {
console.error(`\n cannot restart node, reason: ${err.message}`);
process.exit(1);
return sock.end();
}
console.info(`\n * share ${storjshare_restart.nodeid} restarted`);
process.exit(0);
sock.end();
});
});
4 changes: 2 additions & 2 deletions bin/storjshare-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ sock.on('remote', function(rpc) {
rpc.start(configPath, (err) => {
if (err) {
console.error(`\n failed to start share, reason: ${err.message}`);
process.exit(1);
return sock.end();
}
console.info(`\n * starting share with config at ${configPath}`);
process.exit(0);
sock.end();
});
});
4 changes: 2 additions & 2 deletions bin/storjshare-stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ sock.on('remote', function(rpc) {
rpc.stop(storjshare_stop.nodeid, (err) => {
if (err) {
console.error(`\n cannot stop node, reason: ${err.message}`);
process.exit(1);
return sock.end();
}
console.info(`\n * share ${storjshare_stop.nodeid} stopped`);
process.exit(0);
return sock.end();
});
});

0 comments on commit 2774fdf

Please sign in to comment.