WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Installation via deb #2480

Closed nakinigit closed 4 years ago

nakinigit commented 4 years ago

I'm quite baffled here. downloaded & installed webthings-gateway-ubuntu-bionic-amd64.deb. Had to install nodejs >10. This is on a Linux mint 18.1 machine.

there does not seem to be documentation on this, previously installed on raspi. latest update killed it, so tried my desktop.

So where is the server?

mrstegeman commented 4 years ago

There is documentation available here: https://github.com/mozilla-iot/gateway-deb/blob/master/README.md

The gist is that the server is running in port 8080.

nakinigit commented 4 years ago

Thanks for the reply. I have multiple web based services running on this box, Ubiquity controller among them. Can a change the port from 8080 (used by ubuquity) to something unused?

mrstegeman commented 4 years ago

Yes, you should be able to create/edit /etc/webthings-gateway/config/local.json with something like this:

{
  "ports": {
    "http": <some number>
  }
}

After doing so, you'll need to run sudo systemctl restart webthings-gateway.

nakinigit commented 4 years ago

Made the change. Seems as thought the service starts then stops: sudo systemctl status webthings-gateway ● webthings-gateway.service - Mozilla WebThings Gateway Loaded: loaded (/lib/systemd/system/webthings-gateway.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Thu 2020-04-16 14:45:31 PDT; 5s ago Process: 32287 ExecStart=/usr/bin/webthings-gateway (code=exited, status=127) Main PID: 32287 (code=exited, status=127)

nakinigit commented 4 years ago

closed by accident

mrstegeman commented 4 years ago

Can you show me the exact content of the local.json file? Are there any errors at the end of /etc/webthings-gateway/log/run-app.log?

nakinigit commented 4 years ago

Until I had created /etc/webthings-gateway/config, /etc/webthings-gateway/ was an empty directory. So there is no /etc/webthings-gateway/log/ directory, let alone run-app.log. Here is the config file I created, local.json, (did not previously exist): { "ports": { "http": 8082 } } For what it's worth, It seems that the service was stopping before I ever added that config folder.

mrstegeman commented 4 years ago

Ah, Linux Mint 18.1 is based on Ubuntu 16.04 (Xenial), not 18.04 (Bionic). The package you installed probably won't work.

However, I just tried on a fresh 18.04 install and I did have to install setpriv in order for the package to work properly.

nakinigit commented 4 years ago

So I install setpriv, then what? Do I reinstall the deb, or do I modify the current installation? Have not used setpriv, but according to the man page I need specify a program.

Not seeing a .deb for Xenial, upgrading at this point is an option.

mrstegeman commented 4 years ago

There isn't a build for Xenial.

You can try installing setpriv and then restarting the webthings-gateway service.

nakinigit commented 4 years ago

My mistake, I'm on mint 19.1. I installed setpriv, had to reinstall webthings in order for /etc/webthings-gateway/log to populate. Before making any changes to the port:

● webthings-gateway.service - Mozilla WebThings Gateway
   Loaded: loaded (/lib/systemd/system/webthings-gateway.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-04-17 10:04:12 PDT; 1s ago
 Main PID: 5577 (webthings-gatew)
    Tasks: 12 (limit: 4915)
   CGroup: /system.slice/webthings-gateway.service
           ├─5577 /bin/bash /usr/bin/webthings-gateway
           └─5578 node build/gateway.js

Apr 17 10:04:12 nak-server systemd[1]: webthings-gateway.service: Service hold-off time over, scheduling restart.
Apr 17 10:04:12 nak-server systemd[1]: webthings-gateway.service: Scheduled restart job, restart counter is at 13.
Apr 17 10:04:12 nak-server systemd[1]: Stopped Mozilla WebThings Gateway.
Apr 17 10:04:12 nak-server systemd[1]: Started Mozilla WebThings Gateway.
Apr 17 10:04:12 nak-server webthings-gateway[5577]: Creating database: /etc/webthings-gateway/config/db.sqlite3

And after creating config for port 8082:

● webthings-gateway.service - Mozilla WebThings Gateway
   Loaded: loaded (/lib/systemd/system/webthings-gateway.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2020-04-17 10:04:37 PDT; 3s ago
  Process: 5615 ExecStart=/usr/bin/webthings-gateway (code=exited, status=1/FAILURE)
 Main PID: 5615 (code=exited, status=1/FAILURE)

Apr 17 10:04:37 nak-server systemd[1]: webthings-gateway.service: Main process exited, code=exited, status=1/FAILURE
Apr 17 10:04:37 nak-server systemd[1]: webthings-gateway.service: Failed with result 'exit-code'.

Log files are created, but they are for the most part, empty:

-rw-r--r-- 1 webthings webthings  371 Apr 17 10:04 .8d6537b1984c54e21126c93ffd3345df991e347d-audit.json
-rw-r--r-- 1 webthings webthings    0 Apr 17 10:04 logs.sqlite3
lrwxrwxrwx 1 webthings webthings   22 Apr 17 10:14 run-app.log -> run-app.log.2020-04-17
-rw-r--r-- 1 webthings webthings    0 Apr 17 10:04 run-app.log.2020-04-17
nakinigit commented 4 years ago

P.S, in the editor, I paste text as code, and formatting appears correct (line indent, etc). But when I submit, all that seems to be lost. Any suggestions?

mrstegeman commented 4 years ago

Use triple-backticks instead of single.

mrstegeman commented 4 years ago

I tried with that same config and things start up fine for me...

File: /etc/webthings-gateway/config/local.json Content:

{
  "ports": {
    "http": 8082
  }
}
nakinigit commented 4 years ago

Who is the owner/group for the local.json?

mrstegeman commented 4 years ago

All of /etc/webthings-gateway should be owned by webthings:webthings.

nakinigit commented 4 years ago

OK, up and running. One final detail: when I had this installed on the raspi, I created a subnet. All of my things are on that subnet and it is set up such that the current host machine can see anything on that subnet, but not vice-versa. Is it possible for webthings-gateway run on that subnet without major changes to the host?

mrstegeman commented 4 years ago

There's no reason why that shouldn't be possible. You'll just have to configure your network appropriately.

nakinigit commented 4 years ago

To be clear, the host is 192.168.xx.xxx, I want the webthings-gateway server, hosted on said machine, to appear 0n 192.168.xy.xxx. If this were a virtual host on apache, I could probably figure it out. This is different. So is there a configuration change I need to do on webthings-gateway, as I did with the port?

mrstegeman commented 4 years ago

The server should listen on all interfaces by default, so if your server has multiple network interfaces, e.g. one for each subnet, it should already be listening on all of them.