Skip to content

Commit

Permalink
updates implemeted
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentine-Mario committed Dec 20, 2021
1 parent 542b019 commit 4e27b72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
45 changes: 22 additions & 23 deletions bootstrap/create-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ const fs = require('fs');
const exec_shell = require('./util/exec_script');

const main = async () => {
//take snapshot name from arg
const arg_input = process.argv[2];
if (arg_input === undefined) {
console.log('Please specify snapshot name');
return;
}
try {
//take snapshot name from arg
const arg_input = process.argv[2];
if (arg_input === undefined) {
console.log('Please specify snapshot name');
return;
}

//check if .rnode dir exist
const homedir = require('os').homedir();
if (!fs.existsSync(homedir + '/.rnode')) {
console.log(`Cannot snapshot: ${homedir}/.rnode does not exist`);
return;
}
//check if .rnode dir exist
const homedir = require('os').homedir();
if (!fs.existsSync(homedir + '/.rnode')) {
console.log(`Cannot snapshot: ${homedir}/.rnode does not exist`);
return;
}

//run stop node script
require('child_process').fork('stop-rnode.js');
//run stop node script
require('child_process').fork('stop-rnode.js');

//create snapshot dir
await exec_shell(`mkdir -p snapshot`);
const target = `${__dirname}/snapshot/${arg_input}.tgz`;
//create snapshot dir
fs.mkdirSync('snapshot', { recursive: true });
const target = `${__dirname}/snapshot/${arg_input}.tgz`;

if (fs.existsSync(target)) {
console.log('snapshot already exist');
return;
await exec_shell(`cd ~ && tar czf "${target}" .rnode`);

This comment has been minimized.

Copy link
@Bill-Kunj

Bill-Kunj Dec 20, 2021

Collaborator

If the snapshot already exists, then the user should be alerted and given the opportunity to overwrite.

console.log(`snapshot created: ${target}`);
} catch (error) {
console.log(error);
}

await exec_shell(`cd ~ && tar czf "${target}" .rnode`);
console.log(`snapshot created: ${target}`);
};

main();
2 changes: 1 addition & 1 deletion bootstrap/stop-rnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = async () => {
) {
await exec_shell(`kill ${formatted_string}`);
} else {
console.log('Aboring ...');
console.log('Aborting ...');
}
rl.close();
});
Expand Down

0 comments on commit 4e27b72

Please sign in to comment.