Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request prey/js/prey-node-client!1118
  • Loading branch information
beregcamlost committed Nov 22, 2024
2 parents d06c0b9 + e6d0388 commit 38b144a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [v1.13.6](https://github.com/prey/prey-node-client/tree/v1.13.6) (2024-11-22)
[Full Changelog](https://github.com/prey/prey-node-client/compare/v1.13.5..v1.13.6)

- Fix: Better handling Prey software shutdown cases. ([Beregcamlost](https://github.com/beregcamlost)) ([SoraKenji](https://github.com/SoraKenji))

- Fix: Fix error when getting device status exceeded 3 minutes. ([Beregcamlost](https://github.com/beregcamlost)) ([SoraKenji](https://github.com/SoraKenji))

## [v1.13.5](https://github.com/prey/prey-node-client/tree/v1.13.5) (2024-11-21)
[Full Changelog](https://github.com/prey/prey-node-client/compare/v1.13.4..v1.13.5)

Expand Down
22 changes: 11 additions & 11 deletions lib/agent/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function shutdown(code, wait) {

// we should only remove the pidfile if the agent is really running
// otherwise a second instance would remove the pidfile of the first one
if (agent.running()) {
if (typeof agent.running === 'function' && agent.running()) {
logger.info(`Gracefully shutting down. Will self-destruct in ${wait / 1000} secs.`);

const timer = setTimeout(die, wait);
Expand Down Expand Up @@ -131,40 +131,40 @@ function trap_signals() {
warn('\nLooks like there\'s no config file yet. Glad to see you\'re getting started. :)');
return warn('To finish setting up Prey, please run `prey config hooks post_install` as root.\n', 1);
}

trap_signals();

if (process.argv[2] == 'console') program.mode = 'console';

if (program.allowOther || program.run || program.mode == 'console') {
return agent.run();
}

// if running in console mode, or using -a or -r, pidfile won't
// be available for them to remove on process.exit().
pidfile = common.pid_file;

pid.store(pidfile, (err, running) => {
if (err) {
const msg = err.code == 'EPERM' ? `No write access to pidfile: ${pidfile}` : err.message;
return warn(`Cannot continue: ${msg}`, 1);
}

if (!running) return agent.run();

if (process.stdout.writable) {
warn('\n The Prey agent is running. Good job!');

if (running.stat && running.stat.ctime) {
const run_time = (new Date() - running.stat.ctime) / (60 * 1000);
const run_time_str = run_time.toString().substring(0, 5);
warn(` It has been live for ${run_time_str} minutes, under process ID ${running.pid}.`);
}

warn(' To trigger actions or retrieve information, log in to your Prey account at https://preyproject.com');
warn(' For additional configuration options, please run `prey config`.\n');
}

process.exit(10);
});
});
Expand Down
12 changes: 8 additions & 4 deletions lib/agent/triggers/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ exports.get_status = (cb, nameCallBack = '') => {
exports.statusCallbacks = [];

if (callbacksList.length >= 1) {
callbacksList.forEach((fn) => {
fn(null, null);
callbacksList.forEach((element) => {
if (element && element.cb && element.cb === 'function') {
element.cb(null, null);
}
});
}
}, exports.timeoutGetStatusMs);
Expand All @@ -88,8 +90,10 @@ exports.get_status = (cb, nameCallBack = '') => {
exports.statusCallbacks = [];

if (callbacksList.length >= 1) {
callbacksList.forEach((fn) => {
fn.cb(err, exports.status);
callbacksList.forEach((element) => {
if (element && element.cb && element.cb === 'function') {
element.cb(err, exports.status);
}
});
}
});
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": "prey",
"version": "1.13.5",
"version": "1.13.6",
"author": "Engineering <[email protected]>",
"keywords": [
"prey",
Expand Down

0 comments on commit 38b144a

Please sign in to comment.