Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart doesn't work from Docker on Synology DSM #494

Closed
ashway83 opened this issue Jan 19, 2020 · 4 comments
Closed

Restart doesn't work from Docker on Synology DSM #494

ashway83 opened this issue Jan 19, 2020 · 4 comments
Labels

Comments

@ashway83
Copy link

Describe The Bug:
Restart issues hardcoded command (homebridge-config-ui-x/src/core/config/config.service.ts method setConfigForDocker):

this.ui.restart = 'killall -9 homebridge && killall -9 homebridge-config-ui-x';

After killing those processes, tee processes are still alive, so s6-supervise still believes that homebridge service is alive and neither tries to restart it nor calls finish service script, so TERMINATE_ON_ERROR=1 also doesn't have any effect.

 1128 root      0:00 tee -a /homebridge/logs/homebridge.log 
...
 1241 root      0:00 tee -a /homebridge/logs/homebridge.log 

The issue could be fixed by the correct restart command, but its value in the config.js is ignored.

To Reproduce:
Run oznu/docker-homebridge container on Synology NAS and try to click "Restart" from the Config UI X. Although services are killed, s6-supervise doesn't detect termination.

After issuing killall -9 tee command s6-supervise correctly detects homebridge "service" termination.

Expected behavior:
homebridge services stop correctly, s6-supervise detect termination, executes finish script and based on the TERMINATE_ON_ERROR value, finish script can stop the contain, or homebridge service is restarted.

Logs:

[1/19/2020, 3:46:22 PM] Homebridge is running on port 53689.                                                                  
[1/19/2020, 3:46:36 PM] [Config] Terminal session ended.                                                                      
[1/19/2020, 3:46:42 PM] [Config] Starting terminal session                                                                    
[1/19/2020, 3:47:38 PM] [Config] Homebridge restart request received                                                          
[1/19/2020, 3:47:38 PM] [Config] Terminal session ended.                                                                      
[1/19/2020, 3:47:39 PM] [Config] Executing restart command: killall -9 homebridge && killall -9 homebridge-config-ui-x        
Killed                                                                                                                        
Killed                                                                                                                        
[1/19/2020, 3:47:41 PM] [Config] Homebridge Config UI X v4.8.0 is listening on :: port 8081                                                                                               
[1/19/2020, 3:49:14 PM] [Config] Starting terminal session

Homebridge Config:

{
    "bridge": {
        "name": "Homebridge EEE4",
        "username": "0E:3B:79:C7:EE:E4",
        "port": 53689,
        "pin": "031-45-154"
    },
    "accessories": [
        {
            "accessory": "mqttthing",
            "type": "lightbulb",
            "name": "Test Light",
            "url": "http://localhost:1883",
            "topics": {
                "getOn": {
                    "topic": "stat/arilux-office/RESULT",
                    "apply": "return(JSON.parse(message).POWER1);"
                },
                "setOn": "cmnd/arilux-office/Power1",
                "getHSV": {
                    "topic": "stat/arilux-office/RESULT",
                    "apply": "return(JSON.parse(message).HSBColor);"
                },
                "setHSV": "cmnd/arilux-office/HsbColor"
            },
            "onValue": "ON",
            "offValue": "OFF"
        },
        {
            "accessory": "mqttthing",
            "type": "lightbulb",
            "name": "Test Light RGBW",
            "url": "http://localhost:1883",
            "topics": {
                "getRGBW": "test/hsvlight/getHSV",
                "setRGBW": "cmnd/arilux-office/Color1"
            },
            "logMqtt": true
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8081,
            "auth": "form",
            "theme": "dark-mode",
            "restart": "killall homebridge",
            "tempUnits": "c",
            "debug": false,
            "platform": "config"
        },
        {
            "platform": "openHAB2-Complete",
            "host": "http://localhost",
            "port": "8080",
            "accessories": [
                {
                    "name": "Office LED",
                    "type": "light",
                    "item": "LEDColor1"
                },
                {
                    "name": "Office White",
                    "type": "light",
                    "item": "White1"
                }
            ]
        }
    ]
}

Screenshots:

Environment:

  • Node.js Version: v12.14.1
  • NPM Version: v6.13.4
  • Homebridge Version: 0.4.50
  • Homebridge Config UI X Version: v4.8.0
  • Operating System: Docker
  • Process Supervisor: Docker
@ashway83 ashway83 added the bug label Jan 19, 2020
@ashway83
Copy link
Author

After more extensive testing, it was discovered that the issue occurs when homebridge-openhab2-complete plugin is installed. Still, it should be possible at least to redefine restart command in the config file, that allows to resolve the issue.

@oznu
Copy link
Member

oznu commented Jan 20, 2020

Can you see if this command works instead?

kill -15 $(pidof homebridge); sleep 3; kill -15 $(pidof homebridge-config-ui-x);

Just run it manually at the terminal.

@ashway83
Copy link
Author

@oznu Actually, I have experimented with different commands already. killall does its job well, there is no need to lookup PID with pidof commmand. What makes the difference is the signal which we send to the process. SIGTERM (15) is the default signal that killall sends if signal is not specified explicitly. It allows the process to terminate gracefully closing all the open handles, connections, etc., while SIGKILL should be used as a solution of last resort to terminate hanged/unresponsive processes.
That's being said, I confirm that killall homebridge && killall homebridge-config-ui-x works as expected, as well as the command that you suggested.
Still, I'd insist that there has to be a possibility to override default restart command. Currently, it's confusing to have a command in the configuration file, which is ignored. Also, there might be some scenarios where predefined command doesn't work. Not mentioning that

killall homebridge && killall homebridge-config-ui-x

or your edition:

kill -15 $(pidof homebridge); sleep 3; kill -15 $(pidof homebridge-config-ui-x);

will result in the error in the log file if you don't run Config UI X.

@oznu
Copy link
Member

oznu commented Jan 22, 2020

will result in the error in the log file if you don't run Config UI X.

These commands are only issued if the user restarts from Homebridge Config UI X.

From v4.8.1 SIGTERM will be sent to the Homebridge process first, followed by a SIGKILL after 5.1 seconds, which is normal circumstances won't do anything as Homebridge should kill itself 5 seconds after SIGTERM anyway.

@oznu oznu closed this as completed Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants