burnedikt / diasend-nightscout-bridge

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

Pointers on how to run this on my ubuntu server VM? #16

Closed kamuffelnight closed 1 year ago

kamuffelnight commented 1 year ago

Thank you for creating this project!

Could you/someone give me some pointers on how to run this on my ubuntu server VM? How / where do you guys run it?

I am running my local nightscout instance via docker compose. So I thought it would be easiest, to run this next to it as stanalone service. I´ve messed around with npm/yarn/.. for hours but to be honest I don´t completely understand what I´m doing. So I would greatly appreciate some hints what the steps are to help me figure it out.

burnedikt commented 1 year ago

Given that you're running nightscout via docker compose, are you familiar with docker containers per se? If so, you can pretty easily create a docker container with this project running inside like:

Dockerfile

FROM node:lts-alpine

WORKDIR /usr/local/app

COPY . ./

RUN yarn install
RUN yarn build

CMD [ "node", "dist/run.js" ]

You can then build the image like docker build . and use the resulting container image e.g. in your docker-compose stack like:


# nightscout services

services:
  diasend-bridge:
    image: <name-of-the-built-image> # alternatively, you can also configure a build section here if you don't have the container image readily available via e.g. docker hub
    env:
      DIASEND_USERNAME: <diasend-username>
      DIASEND_PASSWORD: <diasend-password>
      NIGHTSCOUT_URL: <url-of-nightscout-instance>
      NIGHTSCOUT_API_SECRET: <retracted>
      # ... other environment variables for configuration, see readme

Please let me know if that helps!

kamuffelnight commented 1 year ago

You are a legend @burnedikt, that was exactly what I needed - it´s working!! Thanks a lot for your work. I´ve dialed down the polling interval to one minute with the help of your readme file. I wonder if there is a rate limit on the diasend side this could run into. Do you run five minutes yourself?

burnedikt commented 1 year ago

You are a legend @burnedikt, that was exactly what I needed - it´s working!!

Glad to hear that! I might even add that as another way of operating it to the readme (and add the dockerfile to the repo). Thanks for validating it works! 😉

Do you run five minutes yourself?

I am running on a 2 minute polling interval. It's worth noting, though, that there's two parallel polling loops running - one to get glucose values only, the other one to fetch and process treatments. So the request rate will technically be higher on the diasend side. So far, didn't encounter any rate limits there but I can see lower polling intervals becoming a problem at some point.

kamuffelnight commented 1 year ago

Cool. I will keep the one minute polling interval for now.

Heres exactly what I did / "documented" for myself, maybe you can use parts of it for the readme file.

git clone https://github.com/burnedikt/diasend-nightscout-bridge.git
cd diasend-nightscout-bridge
nano index.ts

change polling time in line "const interval = 5 60 1000;", save

nano Dockerfile

content:

FROM node:lts-alpine

WORKDIR /usr/local/app

COPY . ./

RUN yarn install
RUN yarn build

CMD [ "node", "dist/run.js" ]
sudo docker build -t ds2ns .
sudo docker run -d \
  --name=ds2ns1 \
  -e TZ=Europe/Berlin \
  -e DIASEND_USERNAME=abc@def.gh \
  -e DIASEND_PASSWORD=abc \
  -e NIGHTSCOUT_URL=http://1.2.3.4:1337/ \
  -e NIGHTSCOUT_API_SECRET=abc \
  --restart unless-stopped \
  ds2ns:latest