Skip to content

Commit

Permalink
Fixed regression with wake command being called directly
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGustafsson committed Jun 25, 2019
1 parent a3ec018 commit 0b8e91b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/network-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,27 @@ class NetworkDevice {
wol.wake(this.config.mac, options, error => {
if (error)
this.log('An error occured while waking "%s" (%s, %s): %s', this.config.name, this.config.ip || 'unknown ip', this.config.mac, error);
else if (this.config.wakeCommand)
this.log('Attempting to wake up "%s" (%s) using "%s"', this.config.name, this.config.ip || 'unknown ip', this.config.wakeCommand);

if (this.pinger)
this.pinger.start();
});

woke = true;
}

// Wake up using a wake command if available
if (this.config.wakeCommand) {
exec(this.config.wakeCommand, error => {
if (error)
this.log('An error occured while trying to wake "%s" (%s): %s', this.config.name, this.config.ip || 'unknown ip', error);

if (this.pinger)
this.pinger.start();
});
// Further methods of waking up a device such as a "bootCommand" can be added here

woke = true;
// Wake up using a wake command if available
if (woke && this.config.wakeCommand) {
this.log('Waiting for wake grace time ("%d") before executing wake command on "%s" (%s)', this.config.wakeGraceTime, this.config.name, this.config.ip);
setTimeout(() => {
exec(this.config.wakeCommand, error => {
if (error)
this.log('An error occured while trying to wake "%s" (%s): %s', this.config.name, this.config.ip || 'unknown ip', error);

if (this.pinger)
this.pinger.start();
});
}, this.config.wakeGraceTime);
} else if (this.pinger) {
this.pinger.start();
}

if (!woke)
Expand Down

0 comments on commit 0b8e91b

Please sign in to comment.