Skip to content

script error #1

@PSLLSP

Description

@PSLLSP

When "error" script is not defined as an absolute path, unhandled error is reported:

$ signumhealth -V
1.1.0
$ cat error.sh 
#!/bin/sh

echo "ERROR: $0"
$ signumhealth -n http://localhost:8125 -s error.sh
2022-10-21T19:43:20.702Z
http://localhost:8125 - height: 1071428
https://europe.signum.network - height: 1071655
Node [http://localhost:8125] is 227 block(s) behind of Node [https://europe.signum.network] - syncing...
Signature Check:
http://localhost:8125 - signature (height: 1071428): 87feff6fe0c0086cfbe92a527aa9d0b9e12f2e3cf2b74005fc51a07a646a5908bbbf47f688bf77617b6fdb8e5cbe39ef97933dcc0f769f0dad03b1f4507eb908
https://europe.signum.network - signature (height: 1071428): 7a4781a8bf7fa83161eba1406b85d1ed2faa97048aa43183f63bfb92c798930fd65665fe4b2b28711b64e1bab72e0bd48a788de5074f239bff40e5131322d118
❌ 2022-10-21T19:43:20.748Z Health Check failed Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again
Executing [error.sh Error: Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again]
events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: spawn error.sh ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn error.sh',
  path: 'error.sh',
  spawnargs: [
    Error: Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again
        at checkNode (/usr/local/lib/node_modules/signum-node-health-check/src/checkNode.js:46:11)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async /usr/local/lib/node_modules/signum-node-health-check/src/index.js:22:22
  ]
}

Absolute path to the script is passed, it works:

$ signumhealth -n http://localhost:8125 -s "$PWD/error.sh"
2022-10-21T19:43:52.072Z
http://localhost:8125 - height: 1071428
https://europe.signum.network - height: 1071656
Node [http://localhost:8125] is 228 block(s) behind of Node [https://europe.signum.network] - syncing...
Signature Check:
http://localhost:8125 - signature (height: 1071428): 87feff6fe0c0086cfbe92a527aa9d0b9e12f2e3cf2b74005fc51a07a646a5908bbbf47f688bf77617b6fdb8e5cbe39ef97933dcc0f769f0dad03b1f4507eb908
https://europe.signum.network - signature (height: 1071428): 7a4781a8bf7fa83161eba1406b85d1ed2faa97048aa43183f63bfb92c798930fd65665fe4b2b28711b64e1bab72e0bd48a788de5074f239bff40e5131322d118
❌ 2022-10-21T19:43:52.120Z Health Check failed Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again
Executing [/home/ubuntu/signum-node/error.sh Error: Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again]
ERROR: /home/ubuntu/signum-node/error.sh

When error script doesn't have execution right, it fails (in bad way) too:

$ chmod -x error.sh
$ signumhealth -n http://localhost:8125 -s "$PWD/error.sh"
2022-10-21T19:46:12.502Z
http://localhost:8125 - height: 1071428
https://europe.signum.network - height: 1071656
Node [http://localhost:8125] is 228 block(s) behind of Node [https://europe.signum.network] - syncing...
Signature Check:
http://localhost:8125 - signature (height: 1071428): 87feff6fe0c0086cfbe92a527aa9d0b9e12f2e3cf2b74005fc51a07a646a5908bbbf47f688bf77617b6fdb8e5cbe39ef97933dcc0f769f0dad03b1f4507eb908
https://europe.signum.network - signature (height: 1071428): 7a4781a8bf7fa83161eba1406b85d1ed2faa97048aa43183f63bfb92c798930fd65665fe4b2b28711b64e1bab72e0bd48a788de5074f239bff40e5131322d118
❌ 2022-10-21T19:46:12.545Z Health Check failed Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again
Executing [/home/ubuntu/signum-node/error.sh Error: Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again]
events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: spawn /home/ubuntu/signum-node/error.sh EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -13,
  code: 'EACCES',
  syscall: 'spawn /home/ubuntu/signum-node/error.sh',
  path: '/home/ubuntu/signum-node/error.sh',
  spawnargs: [
    Error: Node [http://localhost:8125] is forked from [https://europe.signum.network] - Try popping off to get in sync again
        at checkNode (/usr/local/lib/node_modules/signum-node-health-check/src/checkNode.js:46:11)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
        at async /usr/local/lib/node_modules/signum-node-health-check/src/index.js:22:22
  ]
}

From my point of view, signumhealth should check during start if script is available (it can see it) and that permissions are ok (script is executable). This simple check during start will assure that script will be called when node is in a trouble... Or there should be a new switch to "simulate" trouble, to test that error script is executed....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions