<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                > ### 線上服務器的部署 * 線上服務器不需要安裝Go的開發環境, 也不用將源碼上傳上去 * 只需要找一臺和線上服務器相同的操作系統, 安裝GO環境, 上傳源碼, 生成可執行文件, 將生成的可執行文件放到線上服務器(避免線上服務器出現漏洞時, 被人盜竊源碼, 找出漏洞, 進一步遭受攻擊) * 將本地可執行文件上傳到線上服務器時, 如果用到相對路徑, 那線上服務器放可執行文件的文件, 要和本地生成可執行文件的位置相同 > ### 準備工作 * 說明: 用supervisor 來管理不同服務間的單個或多個實例, 用nginx負載均衡到多個實例 * 定義三個服務, 端口為9001~9003, 將生成的可執行文件放到線上服務器(名稱http-login1, http-login2, http-login3) ~~~ package main import ( "net/http" "fmt" ) func login(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World")) } func main() { http.HandleFunc("/login", login) if err := http.ListenAndServe(":9001", nil); err != nil { fmt.Println(err) } } ~~~ > ### 安裝supervisor 進程管理工具 * supervisord:運行 Supervisor 時會啟動一個進程 supervisord,它負責啟動所管理的進程,并將所管理的進程作為自己的子進程來啟動,而且可以在所管理的進程出現崩潰時自動重啟。 * supervisorctl:是命令行管理工具,可以用來執行 stop、start、restart 等命令,來對這些子進程進行管理。 ~~~ [root@VM_0_17_centos gopath]# yum install supervisor [root@VM_0_17_centos gopath]# systemctl start supervisord.service [root@VM_0_17_centos gopath]# vim /etc/supervisord.conf //systemctl restart supervisord.service (修改完配置沒生效的話重啟下) //找到 ;[program:theprogramname]欄目, 在下一個欄目前添加 //相關配置說明可以看最下方的相關閱讀 [program:golang-http-login1] command=/var/local/gopath/src/http-login1 autostart=true autorestart=true startsecs=10 [program:golang-http-login2] command=/var/local/gopath/src/http-login2 autostart=true autorestart=true startsecs=10 [program:golang-http-login3] command=/var/local/gopath/src/http-login3 autostart=true autorestart=true startsecs=10 [root@VM_0_17_centos gopath]# supervisorctl update golang-http: stopped golang-http: removed process group golang-http-login1: added process group golang-http-login2: added process group golang-http-login3: added process group #根據最新的配置文件,啟動新配置或有改動的進程,配置沒有改動的進程不會受影響而重啟。 //supervisorctl update #啟動進程 //supervisorctl start golang-http-login1 #重啟進程 //supervisorctl restart golang-http-login1 #停止進程 //supervisorctl stop golang-http-login1 #啟動全部進程 //supervisorctl start all #設置開機啟動 //systemctl enable supervisord.service ~~~ > ### 查看服務狀態 ~~~ [root@VM_0_17_centos gopath]# supervisorctl status golang-http-login1 RUNNING pid 15112, uptime 0:01:03 golang-http-login2 RUNNING pid 15113, uptime 0:01:03 golang-http-login3 RUNNING pid 15114, uptime 0:01:03 [root@VM_0_17_centos src]# netstat -tlnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2897/sshd tcp6 0 0 :::9001 :::* LISTEN 15112/http-login1 tcp6 0 0 :::9002 :::* LISTEN 15113/http-login2 tcp6 0 0 :::9003 :::* LISTEN 15114/http-login3 ~~~ > ### 訪問服務 ![img](https://box.kancloud.cn/f49ea3043426d6eb2938187c90ad00a6_675x480.jpg) > ### 圖形界面(修改inet\_http\_server模塊) ![img](https://box.kancloud.cn/5d409595ea44710696632c8c40135f57_618x88.jpg) ![img](https://box.kancloud.cn/924a1d21f86daa902fad7fff904b1a8f_1307x310.jpg) > ### 配置日記(點Name的時候可以看到對應終端輸出) ~~~ [program:golang-http-login3] command=/var/local/gopath/src/http-login3 autostart=true autorestart=true startsecs=10 stdout_logfile=/usr/local/runtime.log ~~~ > ### nginx負載均衡 ~~~ upstream golang-http-login { server 123.207.79.96:9001; server 123.207.79.96:9002; server 123.207.79.96:9003; } server { listen 9000; location / { proxy_pass http://golang-http-login; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ~~~ > ### 相關閱讀 * [supervisor的安裝與簡單介紹](https://www.cnblogs.com/Dicky-Zhang/p/6171954.html)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看