Problem with the Gateway running as daemon on a RPi2B



  • Hello,
    I’ve got 3 Foscam Cameras.
    First trying the proxy and it works.
    Now I want to use the use the Gateway on a RPI2B running openhabian (based on raspbian).
    I used the linux manual. Until step 8 all works fine.
    All cams work at alexa.
    I’ve istalled the service (the following output is from a second run):

    [09:36:45] openhabian@openHABianPi:~/temp$ sudo ./install.sh
    -----------------------------------
    Installing Monocle Gateway
    -----------------------------------
    Installing executables binaries to '/usr/local/bin'
    Creating configuration directory at '/etc/monocle/'
    Creating 'monocle' system user account
    Configuring bind access to system reserved port 443
    Installing systemd service to '/etc/systemd/system/monocle-gateway.service'
    Reloading systemd daemon
    Starting Monocle Gateway service daemon
    Enabling Monocle Gateway service deamon to start automatically
    -----------------------------------
    Monocle Gateway Installed
    -----------------------------------
    [09:37:52] openhabian@openHABianPi:~/temp$
    
    It looks alright, but:
    
    *[09:38:04] openhabian@openHABianPi:~/temp$ sudo monocle-gateway --status
    
     ******************************************************************
     *             __  __  ___  _  _  ___   ___ _    ___              *
     *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
     *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
     *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
     *                                                                *
     ******************************************************************
    
    GETTING <<STATUS>> FOR THE [MONOCLE-GATEWAY] SERVICE
    ● monocle-gateway.service - Monocle Gateway Service
       Loaded: loaded (/etc/systemd/system/monocle-gateway.service; enabled; vendor preset: enabled)
       Active: activating (auto-restart) (Result: exit-code) since Wed 2018-08-29 09:37:55 CEST; 30s ago
     Main PID: 2481 (code=exited, status=1/FAILURE)
    
    Aug 29 09:37:55 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    
    Aug 29 09:37:55 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:37:55 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    
    [09:38:25] openhabian@openHABianPi:~/temp$
    
    [09:38:32] openhabian@openHABianPi:~/temp$ sudo monocle-gateway --start
    
     ******************************************************************
     *             __  __  ___  _  _  ___   ___ _    ___              *
     *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
     *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
     *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
     *                                                                *
     ******************************************************************
    
    <<STARTING>> THE [MONOCLE-GATEWAY] SERVICE
    ● monocle-gateway.service - Monocle Gateway Service
       Loaded: loaded (/etc/systemd/system/monocle-gateway.service; enabled; vendor preset: enabled)
       Active: active (running) since Wed 2018-08-29 09:39:55 CEST; 267ms ago
     Main PID: 2742 (monocle-gateway)
       CGroup: /system.slice/monocle-gateway.service
               └─2742 /usr/local/bin/monocle-gateway
    
    Aug 29 09:39:55 openHABianPi systemd[1]: Started Monocle Gateway Service.
    
    [09:39:55] openhabian@openHABianPi:~/temp$
    
    [09:41:33] openhabian@openHABianPi:~/temp$ sudo monocle-gateway --status
    
     ******************************************************************
     *             __  __  ___  _  _  ___   ___ _    ___              *
     *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
     *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
     *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
     *                                                                *
     ******************************************************************
    
    GETTING <<STATUS>> FOR THE [MONOCLE-GATEWAY] SERVICE
    ● monocle-gateway.service - Monocle Gateway Service
       Loaded: loaded (/etc/systemd/system/monocle-gateway.service; enabled; vendor preset: enabled)
       Active: activating (auto-restart) (Result: exit-code) since Wed 2018-08-29 09:39:58 CEST; 1min 45s ago
      Process: 2742 ExecStart=/usr/local/bin/monocle-gateway (code=exited, status=1/FAILURE)
     Main PID: 2742 (code=exited, status=1/FAILURE)
    
    Aug 29 09:39:58 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    
    [09:41:43] openhabian@openHABianPi:~/temp$*
    

    Also a reboot dontT fix the problem.
    If i start the gateway in putty from the temp folder it works.
    I’m not very familar with linux.
    Can someone help me?

    Dirk

    PS: Some caracters from the log are interpreted as format instructions. Normaly it is possible to poste this lines as code. I don’t figured out how it works here. I hope it is readable.



  • Here’s the log:

    [09:56:26] openhabian@openHABianPi:~/temp$ sudo monocle-gateway --tail
    [sudo] Passwort für openhabian:
    
     ******************************************************************
     *             __  __  ___  _  _  ___   ___ _    ___              *
     *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
     *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
     *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
     *                                                                *
     ******************************************************************
    
    <<TAIL>> LOG FOR THE [MONOCLE-GATEWAY] SERVICE
    -- Logs begin at Wed 2018-08-29 09:32:46 CEST. --
    Aug 29 09:42:02 openHABianPi monocle-gateway[2940]:     at Object.fs.openSync (pkg/prelude/bootstrap.js:483:32)
    
    Aug 29 09:42:02 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:42:02 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:42:02 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    Aug 29 09:44:02 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    Aug 29 09:44:02 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:44:02 openHABianPi systemd[1]: Started Monocle Gateway Service.
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  ******************************************************************
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  *                                                                *
    Aug 29 09:44:03 openHABianPi monocle-gateway[3065]:  ******************************************************************
    Aug 29 09:44:05 openHABianPi monocle-gateway[3065]: pkg/prelude/bootstrap.js:1172
    Aug 29 09:44:05 openHABianPi monocle-gateway[3065]:       throw error;
    Aug 29 09:44:05 openHABianPi monocle-gateway[3065]:       ^
    Aug 29 09:44:05 openHABianPi monocle-gateway[3065]: Error: EACCES: permission denied, open '/etc/monocle/monocle.token'
    Aug 29 09:44:06 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:44:06 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:44:06 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    Aug 29 09:46:06 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    Aug 29 09:46:06 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:46:06 openHABianPi systemd[1]: Started Monocle Gateway Service.
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  ******************************************************************
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  *                                                                *
    Aug 29 09:46:07 openHABianPi monocle-gateway[3183]:  ******************************************************************
    Aug 29 09:46:10 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:46:10 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:46:10 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    Aug 29 09:48:10 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    Aug 29 09:48:10 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:48:10 openHABianPi systemd[1]: Started Monocle Gateway Service.
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  ******************************************************************
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  *                                                                *
    
    Aug 29 09:48:11 openHABianPi monocle-gateway[3309]:  ******************************************************************
    Aug 29 09:48:13 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:48:13 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:48:13 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    
    Aug 29 09:50:13 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    Aug 29 09:50:13 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:50:13 openHABianPi systemd[1]: Started Monocle Gateway Service.
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  ******************************************************************
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  *                                                                *
    Aug 29 09:50:15 openHABianPi monocle-gateway[3405]:  ******************************************************************
    Aug 29 09:50:17 openHABianPi monocle-gateway[3405]: pkg/prelude/bootstrap.js:1172
    
    Aug 29 09:50:17 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:50:17 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:50:17 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    
    Aug 29 09:52:17 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    Aug 29 09:52:17 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:52:17 openHABianPi systemd[1]: Started Monocle Gateway Service.
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  ******************************************************************
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  *                                                                *
    
    Aug 29 09:52:19 openHABianPi monocle-gateway[3514]:  ******************************************************************
    Aug 29 09:52:21 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:52:21 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:52:21 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    
    Aug 29 09:54:21 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    Aug 29 09:54:21 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:54:21 openHABianPi systemd[1]: Started Monocle Gateway Service.
    
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  ******************************************************************
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  *                                                                *
    Aug 29 09:54:22 openHABianPi monocle-gateway[3638]:  ******************************************************************
    
    Aug 29 09:54:24 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:54:24 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:54:24 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    Aug 29 09:56:24 openHABianPi systemd[1]: monocle-gateway.service: Service hold-off time over, scheduling restart.
    
    Aug 29 09:56:24 openHABianPi systemd[1]: Stopped Monocle Gateway Service.
    Aug 29 09:56:24 openHABianPi systemd[1]: Started Monocle Gateway Service.
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  ******************************************************************
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  *             __  __  ___  _  _  ___   ___ _    ___              *
    
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
    
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  *                                                                *
    Aug 29 09:56:26 openHABianPi monocle-gateway[3759]:  ******************************************************************
    
    Aug 29 09:56:28 openHABianPi systemd[1]: monocle-gateway.service: Main process exited, code=exited, status=1/FAILURE
    Aug 29 09:56:28 openHABianPi systemd[1]: monocle-gateway.service: Unit entered failed state.
    Aug 29 09:56:28 openHABianPi systemd[1]: monocle-gateway.service: Failed with result 'exit-code'.
    

    I think, there’s a problem accessing: the token file:
    Aug 29 09:44:05 openHABianPi monocle-gateway[3065]: Error: EACCES: permission denied, open '/etc/monocle/monocle.token’
    But - how to fix this?

    Dirk



  • Hello,

    I’ve changed the rights for the etc/monocle folder with:
    sudo chmod -R 777 /etc/monocle

    There may be a bether way, only allow the monocle user the access, but so it works for me.
    Perhaps the problem is, that I’ve created the folder with an other user before installing the script.
    I don’t know, but now it works.

    Dirk



  • @Dirk ,

    Thanks for the issue report and log files. It certainly looks like a permissions issue with the token file.
    I’ll give this a try and either update the installer script or add an instruction to the notes to allow the monocle user account access to the /etc/monocle folder.



  • Verry fast Support. Tanks for that!
    Thumb up!

    Dirk



  • @dirk

    Just a quick update, the following commands have been added to the install.sh script in the upcoming 0.0.4 release to address this issue.

    # Set group ownership and permissions of config directory
    chgrp -f -R monocle /etc/monocle
    chmod -f -R g+rw /etc/monocle
    

    When the install script runs, it does create a monocle system user account (a user account with no logon capabilities) as well as a monocle group. So the commands above simply set the group ownership to the monocle group and file permissions to allow read and write access to the monocle group.

    Thanks, Robert