djey47 / cool-updown-legacy

NodeJS script to enable scheduled server start/stop. Won't get new features in favor to https://github.com/djey47/cool-updown-nxt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[POWER] investigate on OFF service failures (ssh?)

djey47 opened this issue · comments

  • Start a Linux server
  • Execute OFF command on this serverId

Observations:

  • the server eventually shutdowns as expected. The API does respond only when the connection is lost (probably SSH service is stopped server-side by the shutdown process); it's logically considered as failure by cool-updown backend thus displayed as KO
  • on server side, shutdown command exit code is null (?!)
  • about 20 seconds elapsed between connection established and command result
  • when testing in interactive way, in fact the shutdown command 'blocks' the shell until services are properly stopped
2|cud  | 2023-10-07T10:46:49.137Z - info: =>(...off-server...)
2|cud  | 2023-10-07T10:46:49.269Z - info: (off-server:0) Connected to host via SSH!
2|cud  | 2023-10-07T10:47:19.089Z - debug: (off-server:0) STDOUT:
2|cud  | 2023-10-07T10:47:19.091Z - debug: (off-server:0) STDERR: Password:
2|cud  | 2023-10-07T10:47:19.095Z - debug: (off-server:0) shutdown command exit code: null
2|cud  | 2023-10-07T10:47:19.097Z - error: (off-server:0) Could not connect to host via SSH! - "Password:"

Conclusions:

  • ssh client should return command response as soon as it is executed
  • solved when executing sudo process in background (-b option)