Waline 本可以部署在 Vercel 等平台上,但有一天突然就不能用了,本文记录自己部署基于 MongoDB 数据库的 Waline 服务。
自己动手,丰衣足食,数据安全,速度还快,无人可挡!
123 | test> use fooswitched to db foowaline> |
---|
1234567 | db.createUser( { user: "vvd", pwd: "123456", roles: [ { role: "readWrite", db: "foo" }] }) |
---|
成功运行命令返回结果:
1 | { ok: 1 } |
---|
show users
命令查看结果1234567891011 | foo> show users[ { _id: 'foo.vvd', userId: UUID("91cab2c3-5fae-42fb-9cd4-3c971ff58e3f"), user: 'vvd', db: 'foo', roles: [ { role: 'readWrite', db: 'foo' } ], mechanisms: [ 'SCRAM-SHA-1', 'SCRAM-SHA-256' ] }] |
---|
MONGO_DB
, MONGO_USER
, MONGO_PASSWORD
三个变量~/.bashrc
,按照之前的配置加入上述变量123 | export MONGO_DB=fooexport MONGO_USER=vvdexport MONGO_PASSWORD=123456 |
---|
至此环境配置完毕
12 | npm install @waline/vercelnode node_modules/@waline/vercel/vanilla.js |
---|
123456 | waline$ node node_modules/@waline/vercel/vanilla.js[2022-08-31T17:17:30.583] [296133] [INFO] - Server running at http://127.0.0.1:8360[2022-08-31T17:17:30.585] [296133] [INFO] - ThinkJS version: 3.2.14[2022-08-31T17:17:30.586] [296133] [INFO] - Environment: production[2022-08-31T17:17:30.586] [296133] [INFO] - Workers: 1[2022-08-31T17:22:07.683] [296140] [INFO] - |
---|
http://IP:8360
访问 waline 页面:测试评论
1234567891011121314 | [2022-08-31T17:22:25.285] [296140] [DEBUG] - Post Comment Start![2022-08-31T17:22:25.285] [296140] [DEBUG] - Post Comment initial Data: { link: 'www.zywvvd.com', mail: 'zywvvd@mail.ustc.edu.cn', nick: 'VVD', pid: 'undefined', rid: 'undefined', ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36', url: '/', comment: '测试?<img class="wl-emoji" src="//unpkg.com/@waline/emojis@1.0.1/weibo/weibo_joy.png" alt="weibo_joy">', ip: '::ffff:180.171.132.122', insertedAt: '2022-08-31T09:22:25.285Z', user_id: 'undefined'} |
---|
/usr/local/waline
/lib/systemd/system
文件夹创建 waline.service
文件
123456789101112131415 | [Unit]Description = Service for waline backendAfter = network.target[Service]ExecStart = /usr/bin/node node_modules/@waline/vercel/vanilla.jsWorkingDirectory = /usr/local/waline/StandardOutput = inheritStandardError = inheritRestart = alwaysUser = lighthouse[Install]WantedBy=multi-user.target |
---|
1 | sudo systemctl enable waline.service |
---|
1 | sudo systemctl start waline.service |
---|
12345678910111213141516 | $ systemctl status waline.service● waline.service - Service for waline backend Loaded: loaded (/lib/systemd/system/waline.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-08-31 18:08:29 CST; 9s ago Main PID: 304641 (node) Tasks: 18 (limit: 3988) Memory: 131.8M CGroup: /system.slice/waline.service ├─304641 /usr/bin/node node_modules/@waline/vercel/vanilla.js └─304662 /usr/bin/node /usr/local/waline/node_modules/@waline/vercel/vanilla.jsAug 31 18:08:30 VM-16-11-ubuntu node[304641]: [2022-08-31T18:08:30.082] [304641] [INFO] - Server running at http://127.0.0.1:8360Aug 31 18:08:30 VM-16-11-ubuntu node[304641]: [2022-08-31T18:08:30.085] [304641] [INFO] - ThinkJS version: 3.2.14Aug 31 18:08:30 VM-16-11-ubuntu node[304641]: [2022-08-31T18:08:30.085] [304641] [INFO] - Environment: productionAug 31 18:08:30 VM-16-11-ubuntu node[304641]: [2022-08-31T18:08:30.085] [304641] [INFO] - Workers: 1 |
---|