{"action":"created","issue":{"url":"https://api.github.com/repos/SignalK/signalk-server-node/issues/548","repository_url":"https://api.github.com/repos/SignalK/signalk-server-node","labels_url":"https://api.github.com/repos/SignalK/signalk-server-node/issues/548/labels{/name}","comments_url":"https://api.github.com/repos/SignalK/signalk-server-node/issues/548/comments","events_url":"https://api.github.com/repos/SignalK/signalk-server-node/issues/548/events","html_url":"https://github.com/SignalK/signalk-server-node/issues/548","id":327978424,"node_id":"MDU6SXNzdWUzMjc5Nzg0MjQ=","number":548,"title":"Allow running a SignalK Server with a simple include","user":{"login":"codefoster","id":1494781,"node_id":"MDQ6VXNlcjE0OTQ3ODE=","avatar_url":"https://avatars3.githubusercontent.com/u/1494781?v=4","gravatar_id":"","url":"https://api.github.com/users/codefoster","html_url":"https://github.com/codefoster","followers_url":"https://api.github.com/users/codefoster/followers","following_url":"https://api.github.com/users/codefoster/following{/other_user}","gists_url":"https://api.github.com/users/codefoster/gists{/gist_id}","starred_url":"https://api.github.com/users/codefoster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codefoster/subscriptions","organizations_url":"https://api.github.com/users/codefoster/orgs","repos_url":"https://api.github.com/users/codefoster/repos","events_url":"https://api.github.com/users/codefoster/events{/privacy}","received_events_url":"https://api.github.com/users/codefoster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-05-31T03:15:07Z","updated_at":"2018-05-31T19:28:51Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"The fastest way I currently know of to create a new SignalK Server is to clone the `signalk-server-node` repository and then customize it. That's not too bad an option, but in my opinion I should be able to create my own Node.js project, run `npm install signalk-server`, write this code...\r\n\r\n``` js\r\nconst SignalKServer = require('signalk-server');\r\nlet server = new SignalKServer({ settings: 'settings.json' });\r\nserver.start();\r\n```\r\n\r\n...and have a running server.\r\n\r\nI realize this doesn't seem like a pressing issue because there's a workaround - just clone the repo - but I'm strongly of the opinion that this isn't the best way to start a project. Allowing it to be included into another Node project gives the developer more options such as...\r\n\r\n- running the server conditionally\r\n- using a process manager\r\n- coordinating the running SignalK server with other processes on the same device\r\n\r\nIt doesn't seem the project is too far from it. I gave a shot at it, but I'm still trying to figure out some of the bootstrapping that happens with a server - loading settings files, providers, interfaces (?), modules, etc. and decided to pause the effort for now.\r\n\r\nThe first roadblock I ran into is that the Server is looking for its settings file with a path that's relative to the package root (see `lib/config/config.js:253`). I can set the settings file absolutely using the SIGNALK_NODE_SETTINGS environment variable, but that's not ideal. The absolute path is harder to maintain, and IMO, the environment variable, should not be necessary. I should be able to set it by passing in the option.\r\n\r\nThe next roadblock is this...\r\n\r\n``` bash\r\n{ Error: ENOENT: no such file or directory, scandir 'C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib/../node_modules/'\r\n    at Object.fs.readdirSync (fs.js:893:3)\r\n    at findModulesInDir (C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\modules.js:54:6)\r\n    at modulesWithKeyword (C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\modules.js:40:5)\r\n    at startPlugins (C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\interfaces\\plugins.js:140:5)\r\n    at Object.start (C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\interfaces\\plugins.js:37:7)\r\n    at C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\index.js:239:60\r\n    at C:\\code\\azureafloat\\simple-server\\node_modules\\lodash\\lodash.js:4925:15\r\n    at Function.forIn (C:\\code\\azureafloat\\simple-server\\node_modules\\lodash\\lodash.js:12949:11)\r\n    at startInterfaces (C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\index.js:225:5)\r\n    at C:\\code\\azureafloat\\simple-server\\node_modules\\signalk-server\\lib\\index.js:138:7\r\n```\r\n\r\nI didn't try to hard to figure that one out before submitting this issue.\r\n\r\n/cc: @taggie05\r\n"},"comment":{"url":"https://api.github.com/repos/SignalK/signalk-server-node/issues/comments/393650187","html_url":"https://github.com/SignalK/signalk-server-node/issues/548#issuecomment-393650187","issue_url":"https://api.github.com/repos/SignalK/signalk-server-node/issues/548","id":393650187,"node_id":"MDEyOklzc3VlQ29tbWVudDM5MzY1MDE4Nw==","user":{"login":"codefoster","id":1494781,"node_id":"MDQ6VXNlcjE0OTQ3ODE=","avatar_url":"https://avatars3.githubusercontent.com/u/1494781?v=4","gravatar_id":"","url":"https://api.github.com/users/codefoster","html_url":"https://github.com/codefoster","followers_url":"https://api.github.com/users/codefoster/followers","following_url":"https://api.github.com/users/codefoster/following{/other_user}","gists_url":"https://api.github.com/users/codefoster/gists{/gist_id}","starred_url":"https://api.github.com/users/codefoster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codefoster/subscriptions","organizations_url":"https://api.github.com/users/codefoster/orgs","repos_url":"https://api.github.com/users/codefoster/repos","events_url":"https://api.github.com/users/codefoster/events{/privacy}","received_events_url":"https://api.github.com/users/codefoster/received_events","type":"User","site_admin":false},"created_at":"2018-05-31T19:28:51Z","updated_at":"2018-05-31T19:28:51Z","author_association":"CONTRIBUTOR","body":"@tkurki, at this point I'm only looking for running with separate configs, but I was thinking that my solution would cover both of the cases you mentioned - allowing for separate configs and embedding.\r\nI didn't know about setting the SIGNALK_NODE_CONFIG_DIR variable. So would I be able to use a project that only pulls SignalK in as an npm install and not clone it? I'll try that."}}
{"actor":{"display_login":"codefoster"}}