去评论
dz插件网

Heroku 上部署 Rust 版 ServerStatus 云探针

xiao9469
2023/12/13 07:58:23
濡備綍鍦 Heroku 涓婇儴缃 Rust 鐗 ServerStatus 浜戞帰閽

鏈暀绋嬭缁嗕粙缁嶅浣曞湪 Heroku 骞冲彴涓婇儴缃 Rust 鐗堢殑 ServerStatus 浜戞帰閽堛

涓銆佸畨瑁 Heroku CLI

Heroku CLI 鏄鐞嗗拰杩愯 Heroku 搴旂敤绋嬪簭蹇呭鐨勫懡浠よ宸ュ叿銆

1. 鍦 Ubuntu/Debian 涓婂畨瑁

瀹夎 CLI , 涓嬭浇鍜岀紪杈戞枃浠堕渶瑕佷互涓嬪伐鍏:

unzip, git, curl, wget, nano, vim


浣跨敤瀹樻柟瀹夎鑴氭湰涓閿畨瑁:

curl https://cli-assets.heroku.com/install.sh | sh

瀹夎澶氳处鎴风鐞嗘彃浠:

heroku plugins:install heroku-accounts

2. 鐧诲綍璐︽埛

浠 [email聽protected] 涓轰緥,璐﹀彿瀵嗙爜涓 Heroku Dashboard 涓婄殑 API Key锛圓count 閲岋級:


heroku accounts:add [email聽protected]  
Enter your Heroku credentials.
Email: [email聽protected]  
Password: ********

鍒囨崲璐︽埛鍛戒护:

heroku accounts:set 璐︽埛鍒悕  

浜屻侀儴缃插簲鐢

1. 鍑嗗鏂囦欢

鍦ㄦ湰鍦板垱寤烘枃浠跺す,涓嬭浇鎵闇鏂囦欢:

- stat_server:缂栬瘧濂界殑 Rust 浜岃繘鍒剁▼搴
- config.toml:閰嶇疆鏂囦欢
- Procfile:鐢ㄤ簬瀹氫箟 dyno 杩愯鍛戒护

mkdir ServerStatus-Rust && cd ServerStatus-Rust

# 涓嬭浇绀轰緥浠 v1.7.2 涓轰緥
wget https://github.com/zdz/ServerSta ... nown-linux-musl.zip  

unzip server-x86_64-unknown-linux-musl.zip
rm -f stat_server.service server-x86_64-unknown-linux-musl.zip

wget https://github.com/kissyouhunter ... oku/heroku/Procfile

2. 鍒涘缓搴旂敤

鍦 Heroku CLI 涓垱寤哄簲鐢,浠 `serverstatus-rust-heroku` 涓轰緥:

heroku apps:create serverstatus-rust-heroku

璁剧疆鑷畾涔 buildpacks:

heroku buildpacks:set https://github.com/kissyouhunter/heroku-empty-build.git -a serverstatus-rust-heroku


3. 閮ㄧ讲浠g爜

鍒濆鍖 git 浠撳簱骞跺皢 heroku app 浣滀负 remote:

git init
git config user.email "[email聽protected]"
heroku git:remote -a serverstatus-rust-heroku
git checkout -b main
git branch -D master

娣诲姞鏂囦欢鍒 git 涓悗 push 鍒 heroku 鍗冲彲閮ㄧ讲:

git add .
git commit -m "deploy app"
git push heroku main

涓夈佽嚜瀹氫箟鍩熷悕涓 SSL

鑻ヨ娣诲姞鑷畾涔夊煙鍚嶅拰 SSL,闇瑕佸皢 Dyno 绫诲瀷璁剧疆涓 Basic 鎴栦互涓娿

1. 鏇存敼 Dyno 绫诲瀷

鏌ョ湅褰撳墠绫诲瀷:

heroku ps:type -a serverstatus-rust-heroku

璁剧疆涓 Basic 鍨:

heroku ps:type basic -a serverstatus-rust-heroku

2. 娣诲姞鍩熷悕

鍦 Heroku Dashbord 鐨 `Settings` - `Domain` 涓坊鍔犲煙鍚,骞跺皢鐢熸垚鐨 DNS Target 娣诲姞鍒板煙鍚嶇殑 CNAME 涓

璁块棶 http://鍩熷悕.com 楠岃瘉鏄惁鐢熸晥銆



3. 寮鍚 SSL

鍦 `SSL Certificates` 涓偣鍑 `Configure SSL`,閫夋嫨 `Automatic Certificate Management (ACM)`銆

鐜板湪灏辨槸鍙互閫氳繃 HTTPS 璁块棶鎺㈤拡浜嗐




鍥涖佸悗缁搷浣

- 姣忔淇敼 config.toml 鍚庨渶瑕 push 涓娆′唬鐮佷互搴旂敤鏇存敼銆

git add . && git commit -m "update" && git push heroku main

- 濡傛灉浣跨敤 1.7.2 閮ㄧ讲涓嶆垚鍔,灏濊瘯 1.7.1 鎴栧叾浠栫増鏈

PS: Heroku 鐜板湪鍚冨鐢熷寘鍚庡彲浠ヨ嶄袱骞