NS安装-CentOS服务器安装Nightscout CGM

时间:2024-02-25 12:22:34

NS CGM 安装必要条件

  1. 有自己的云服务器
  2. 好像没有2,有云服务器就行了

安装顺序

  1. 先安装数据库,目前支持的是 MongoDB ,官方推荐4,其实目前最新版本就行。可以用宝塔安装,比较简单
  2. 克隆代码,我是放到 /opt/ns 目录中了
  3. 安装nodejs,进入代码目录,运行 npm install
  4. 启动cgm

具体代码

yum install epel-release

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | bash
nvm install 16.20.1
nvm use 16.20.1


cd /opt
git clone https://github.com/nightscout/cgm-remote-monitor.git
ln -s cgm-remote-monitor nightscout
cd nightscout

npm i

npm install pm2 -g

# 这里需要创建一个 my.env ,保存配置文件,文件内容见下方

env $(cat my.env)  PORT=1337 pm2 start server.js

pm2 save

pm2 startup
pm2 unstartup systemd

my.env 配置文件,官方有个工具,可以用这个工具生成配置:

 https://nightscout.github.io/_downloads/8ff7fa269d11fd145d3ac558602ade94/NightscoutVariablesUbuntu.html

ALARM_HIGH=on
ALARM_LOW=on
ALARM_TIMEAGO_URGENT=on
ALARM_TYPES=simple
ALARM_TIMEAGO_WARN=on
ALARM_URGENT_HIGH=on
ALARM_URGENT_LOW=on
BRIDGE_SERVER=US
DISPLAY_UNITS=mmol/l
NIGHT_MODE=on
THEME=colors
TIME_FORMAT=24
ALARM_TIMEAGO_URGENT_MINS=30
ALARM_TIMEAGO_WARN_MINS=15
BASE_URL=http://127.0.0.1:1337
API_SECRET=111111111111111111111111
BG_HIGH=260
BG_LOW=55
BG_TARGET_BOTTOM=70
BG_TARGET_TOP=180
BOLUS_RENDER_OVER=1
BRIDGE_PASSWORD=
BRIDGE_USER_NAME=
CUSTOM_TITLE=Nightscout
ENABLE=careportal%20basal%20dbsize%20rawbg%20iob%20maker%20cob%20bwp%20cage%20iage%20sage%20boluscalc%20pushover%20treatmentnotify%20loop%20pump%20profile%20food%20openaps%20bage%20alexa%20override%20speech%20cors
MONGO_CONNECTION=mongodb://127.0.0.1:27017/ns
SHOW_PLUGINS=careportal%20dbsize

PORT=1337
HOSTNAME=0.0.0.0

 

配置一下nginx,做个代理

location / {
		proxy_pass http://127.0.0.1:1337;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection 'upgrade';
		proxy_set_header Host $host;
		proxy_cache_bypass $http_upgrade;
		proxy_set_header X-Forwarded-Proto "https";
	}

location /translations/ {
  
}
location /bundle/ {}
location /js/ {}