Closed mmccool closed 6 years ago
Actually, I think there might be other issues with the configuration files. When I tried to set up the following configuration file, based on the master branch of node-wot as of Nov 2,
{
"servient": {
"scriptDir": "/home/mmccool/Dev/node-wot/examples/scripts",
"scriptAction": false
},
"http": {
"port": 8081
},
"log": {
"level": 3
}
}
I got the output below after running wot-servient in the "scripts" directory. Note that it seems to strip the leading / from the absolute path I gave it. However, I want an absolute path so I can set up a service with systemd and not worry about where the wot-servient command will be started. I can get around the issue by writing a "wrapper" script, or running in a docker container, but...
WoT-Servient using conf file wot-servient.conf.json
DefaultServient configured { servient:
{ scriptDir: '/home/mmccool/Dev/node-wot/examples/scripts',
scriptAction: false },
http: { port: 8081 },
log: { level: 3 } }
HttpServer starting on port 8081
HttpClientFactory for 'http' initializing
DefaultServient started
WoT-Servient experienced error while loading directory { Error: ENOENT: no such file or directory,
scandir 'home/mmccool/Dev/node-wot/examples/scripts'
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: 'home/mmccool/Dev/node-wot/examples/scripts' }
The reason I was doing this was just so I could run on a different port, as I was already running a Thing Directory on port 8080. This is a common enough configuration issue that an explicit command line argument for this (and maybe the other items) would be useful. To get around this problem I reconfigured my Thing Directory to run on a different port. I was able to run wot-servient fine both with no config file, and with a config file in the parent directory using a relative path ("scripts") (although... to get port 8081 working, I had to edit counterClient.js...).
Also... if there are multiple scripts for multiple servients, what if I want to assign different ports to each? What if I want to use https? It would be nice to pass the configuration information down to each scripts as well, perhaps as a command-line argument (for instance, to look up the port a given service is running on).
BTW, I am running into this yet again as I try to set up online tests. I have to run a bunch of different services on different ports, want to autostart them (see need above for absolute paths to config files), and need to control the base urls used (I may not want to expose all interfaces, and/or many know the service will be exposed through a proxy or have a name (eg via Dynamic DNS) I can use instead of an IP address...).
Now can use the flag -f
.
Updated help of cli: wot-servient -h
.
Closing.
There should be a command-line option to provide a path to the wot-servient configuration file, rather than just looking in the "current directory". This will make it easier to run wot-servients as services, i.e. with systemd.