自建VPS库存监控系统 vps.ck.mk

直达 https://vps.ck.mk/

我抄的是这个大佬的作业

https://github.com/qsbaq/vps-stock-monitor

下载安装

cd /data
git clone https://github.com/qsbaq/vps-stock-monitor
cd vps-stock-monitor

# 如果出现这个错误
# ModuleNotFoundError: No module named 'vpsmonitor.settings'
cp vpsmonitor/settings_local.py vpsmonitor/settings.py
pip3 install django
python3 manage.py makemigrations --merge ; python3 manage.py migrate
# 创建后台超级用户
python3 manage.py createsuperuser

LP1VP

反代+启动

# 加好反代 vps.ck.mk
# 去vpsmonitor/settings.py做个修改,把vps.ck.mk加入到ALLOWED_HOSTS里面去
# 随便哪个端口都可以,反正要反代
python3 manage.py runserver 0.0.0.0:8200

配置商家和商品

打开 https://vps.ck.mk/admin 登录后就看到

要先加入商家信息 – 网址链接类似 https://bwh88.net/aff.php?aff=37266&pid=

pid=后面要空着,在商品配置中会用到

加入商品信息 – 一定要确定商家和PID.

建立开机自启动

# systemd
cat > /etc/systemd/system/vps_stock_monitor.service <<EOF
[Unit]
Description=VPS_Stock_Monitor
After=network.target

[Service]
User=root
Type=simple
ExecStart=/usr/bin/python3 /data/vps-stock-monitor/manage.py runserver 0.0.0.0:8200
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl restart vps_stock_monitor
systemctl status vps_stock_monitor
systemctl enable  vps_stock_monitor

定时监控/Crontab

crontab -e
# 末尾加入以下的两行
#check every 15 minutes for stock
*/15 * * * * /usr/bin/python3 /data/vps-stock-monitor/manage.py run >> /data/vps-stock-monitor/refreshing.log 2>&1 &

Leave a Reply