burnedikt / diasend-nightscout-bridge

Synchronize your diasend data to nightscout.
MIT License
18 stars 18 forks source link

After nightscout merge, startup reporting js errors in google cloud #20

Closed muthijammy closed 1 year ago

muthijammy commented 1 year ago

I installed npm diasend-nightscout-bridge package and trying to run merged ns as plugin. But get js script errors.

Following is what I did on google cloud ns:

  1. Download diasend-nightscout-bridge.tar.gz file from https://github.com/burnedikt/diasend-nightscout-bridge/releases/tag/v1.0.0

  2. Switch to terminal on vm using option#13 in utility. Use "upload file" option in terminal right top menu.

  3. Run 3 commands one by one for npm install.

    tar -xv diasend-nightscout-bridge-0.7.8.tar.gz cd diasend-nightscout-bridge-0.7 8 npm install

  4. Add " diasend " to ENABLE, DIASEND_USERNAME,DIASEND_PASSWORD heroku variables using option#5 "edit variables using browser" in utility and pasting URL into browser

DIASEND_USERNAME: the username / email address of your disasend account DIASEND_PASSWORD: the password of your disasend account.

  1. Merge bridge plugin changes into ur uptodate custom nightscout fork branch. See snapshot. Make sure top target part is ur custom nightscout fork branch, not nightscout master

  2. Go back to utility and finish running phase I & II using google cloud usual instructions.

  3. Use below option to deploy ns from ur custom branch where merge done.

https://navid200.github.io/xDrip/docs/Nightscout/Customize.html

But I get this repeatedly and I have stopped VM for now. Any idea what I have done wrong?

Ensuring indexes ensuring index for: date ensuring index for: type ensuring index for: sgv ensuring index for: mbg ensuring index for: sysTime ensuring index for: dateString ensuring index for: [object Object] ensuring index for: created_at ensuring index for: eventType ensuring index for: insulin ensuring index for: carbs ensuring index for: glucose ensuring index for: enteredBy ensuring index for: boluscalc.foods._id ensuring index for: notes ensuring index for: NSCLIENT_ID ensuring index for: percent ensuring index for: absolute ensuring index for: duration ensuring index for: [object Object] ensuring index for: created_at ensuring index for: NSCLIENT_ID ensuring index for: startDate ensuring index for: type ensuring index for: position ensuring index for: hidden ensuring index for: created_at Executing setupListeners Executing setupBridge Dexcom bridge not enabled Executing setupMMConnect MiniMed Connect not enabled Executing setupDiasend /nightscout_start/cgm-remote-monitor/node_modules/http-cookie-agent/dist/create_cookie_agent.js:16 jar; ^

SyntaxError: Unexpected token ; at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/nightscout_start/cgm-remote-monitor/node_modules/http-cookie-agent/dist/index.js:4:29) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

burnedikt commented 1 year ago

Supporting any kind of nightscout installation is out-of-scope for this project but generally, as lined out in the readme there are two ways to run the diasend-nightscout-bridge alongside your nightscout installation:

  1. as a separate service running independently of nightscout and using nightscout's HTTP API to push glucose values and treatments
  2. as a plugin within nightscout, using direct database access to push glucose values and treatments. The sample implementation of this is my fork of nightscout.

As far as I can tell, you're trying to use option 2 (running the bridge as part of nightscout as a plugin) but what I do not understand is why you manually upload and install the bridge. The fork of nightscout already installs the diasend-nightscout-bridge as a dependency via npm so no manual upload or installation should be necessary.

I haven't tried the xdrip installer you referenced myself but from the brief glimpse I got, it should be enough if you just specify your fork's details there and no additional steps should be required with npm or uploading the plugin.

So just specify User ID as muthijammy, Repository as cgm-remote-monitor and Branch as master and you should be good to go. The only thing you should still need to do is to edit the variables and ensure to set:


on another note, you might want to update your fork of nightscout again with my latest changes, to profit from v1.0.0 of the bridge

muthijammy commented 1 year ago

Nigthscout Plugin To run this bridge as a plugin directly in nightscout, you can simply install the bridge as an npm package within your nightscout installation and implement a handler to import the data directly into nightscout. A sample implementation can be found here: https://github.com/nightscout/cgm-remote-monitor/compare/master...burnedikt:cgm-remote-monitor:master?expand=1.

muthijammy commented 1 year ago

Same error even when I deleted VM after DB backup and creating new VM. Setup google cloud following instructions and confirm it shows UI.

  1. Add " diasend " to ENABLE, DIASEND_USERNAME,DIASEND_PASSWORD TZ heroku variables using option#5 "edit variables using browser" in utility and pasting URL into browser DIASEND_USERNAME: the username / email address of your disasend account DIASEND_PASSWORD: the password of your disasend account. TZ DISPLAY_UNITS

  2. Merge bridge plugin changes into ur uptodate custom nightscout fork branch. See snapshot. Make sure top target part is ur custom nightscout fork branch, not nightscout master

  3. Use below option to deploy ns from ur custom branch where merge done.

https://navid200.github.io/xDrip/docs/Nightscout/Customize.html

Got same error. No change

burnedikt commented 1 year ago

To run this bridge as a plugin directly in nightscout, you can simply install the bridge as an npm package within your nightscout installation and implement a handler to import the data directly into nightscout. A sample implementation can be found here: https://github.com/nightscout/cgm-remote-monitor/compare/master...burnedikt:cgm-remote-monitor:master?expand=1.

My fork shows an example implementation of the steps (installing bridge via nom and implementing handlers). That means that if you're using my fork, you don't need to do it change anything. The manual installation of the bridge via npm and implementation of handlers is only required if you're running a custom fork of Nightscout that does not build on my fork. I.e. in your case, no extra steps required as you incorporated all of my Nightscout fork within yours.

burnedikt commented 1 year ago

Same error even when I deleted VM after DB backup and creating new VM. Setup google cloud following instructions and confirm it shows UI.

  1. Add " diasend " to ENABLE, DIASEND_USERNAME,DIASEND_PASSWORD TZ heroku variables using option#5 "edit variables using browser" in utility and pasting URL into browser

DIASEND_USERNAME: the username / email address of your disasend account

DIASEND_PASSWORD: the password of your disasend account.

TZ

DISPLAY_UNITS

  1. Merge bridge plugin changes into ur uptodate custom nightscout fork branch. See snapshot. Make sure top target part is ur custom nightscout fork branch, not nightscout master

  2. Use below option to deploy ns from ur custom branch where merge done.

https://navid200.github.io/xDrip/docs/Nightscout/Customize.html

Got same error. No change

I don't know what the xdrip installer does under the hood and how it configures the VM. All I I is is that if you use my Nightscout fork and run npm install + npm run start, it works as expected. So my guess is the xdrip installer you're using is doing something differently.

I would be happy to support you and dig into this but I don't have a Google Cloud / GCP subscription to test on right now ...

muthijammy commented 1 year ago

Just for clarity,

Even though link I shared is in xdrip path, it has no relation to xdrip and only relates to ns on google cloud. Any client including xdrip, AAPS can upload it.

Usually, Like most ns users, we are dumb of what happens internally. So, apart from merging and deploying, Do I need to do anything on npm? Except last comment, all other comment seem no. But last comment mention "run npm install + npm run start" again. If yes, which folder should I run which commands?

Google cloud is free for 3 months but u need to spend ur precious time and provide credit card once u follow instructions in the link.

To me, compile error reported in js seem to indicate some version incompatilbility issues. Sorry for trouble. May be can u make detailed readme for railway users like me to setup this?

burnedikt commented 1 year ago

Even though link I shared is in xdrip path, it has no relation to xdrip and only relates to ns on google cloud. Any client including xdrip, AAPS can upload it.

Yep but from my understanding, this command-line installation tool for nightscout is somehow built by xdrip or their community. But sorry for the ambiguity, I'm aware that xdrip is an entirely different kind of animal.

Usually, Like most ns users, we are dumb of what happens internally. So, apart from merging and deploying, Do I need to do anything on npm? Except last comment, all other comment seem no. But last comment mention "run npm install + npm run start" again. If yes, which folder should I run which commands?

you don't need to run anything, if you are building your nightscout based on my fork. The instructions for npm install and npm run ... only apply if you are NOT running of my fork of cgm-remote-monitor / nightscout.

To me, compile error reported in js seem to indicate some version incompatilbility issues. Sorry for trouble. May be can u make detailed readme for railway users like me to setup this?

Me, personally, I am running nightscout on railway since the changes in pricing policy on heroku. And the migration from heroku to railway was very simple. I followed this guide. If you're already running on railway, then I don't see any reason why you're trying to setup nightscout on Google Cloud now?


Instructions for Railway (to my best knowledge)

On railway, you can just

  1. create a new project
  2. choose "Deploy from github repo" image
  3. authorize railway to access your nightscout fork / repository on github via the "configure github app" button image
  4. select your repo / fork of nightscout image
  5. within the variables section, add all the required (environment) variables for nightscout, including the ones mentioned above (TZ, DIASEND_USERNAME, DIASEND_PASSWORD, ENABLE. Should look similar to the following screenshot in the end image

And just to restate this, there's no custom steps you need to execute here. Just create the project on railway, select your nightscout repository on github with the changes of my fork already merged (which is the case afaik), configure the variables and let railway do the heavy lifting.

burnedikt commented 1 year ago

@muthijammy Did the above help you getting it set up?

burnedikt commented 1 year ago

Closing this as I haven't heard back anymore. Feel free to reopen if you need further assistance.