diff --git a/Service%EF%BC%9AOpenCode.md b/Service%EF%BC%9AOpenCode.md new file mode 100644 index 0000000..c595708 --- /dev/null +++ b/Service%EF%BC%9AOpenCode.md @@ -0,0 +1,51 @@ +# 簡介 + +# 下載 OpenCode + +```bash +curl -fsSL https://opencode.ai/install | bash +``` + +# 建立 OpenCode 服務 + +設定使用者名稱與密碼 + +```bash +echo 'export OPENCODE_SERVER_USERNAME=jiantw83' >> ~/.bashrc +``` + +```bash +echo 'export OPENCODE_SERVER_PASSWORD=*%QOSYn3Rcc&r*xuWn&q' >> ~/.bashrc +``` + +以 systemd 管理服務,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。 + +```bash +nano /etc/systemd/system/opencode.service +``` + +服務檔內容如下: + +```ini +[Unit] +Description=OpenCode + +[Service] +Environment=HOME=/root +Type=simple +WorkingDirectory=/root +ExecStart=/root/.opencode/bin/opencode serve --hostname 0.0.0.0 --mdns true --mdns-domain opencode.jsc.idv.me +Restart=always +User=root + +[Install] +WantedBy=multi-user.target +``` + +# 啟動服務 + +重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。 + +```bash +systemctl daemon-reload && systemctl enable ezbookkeeping.service && systemctl start ezbookkeeping.service && systemctl status ezbookkeeping.service +``` \ No newline at end of file