Golang(15)Deployment

Golang(15)Deployment,第1张

概述Golang(15)Deployment 1. Installtion >git clone https://github.com/Supervisor/supervisor Right now the version is 4.0-dev, so >mv supervisor supervisor-4.0.0-dev try to install that from command as fol

Golang(15)Deployment

1. Installtion
>git clone https://github.com/Supervisor/supervisor

Right Now the version is 4.0-dev,so
>mv supervisor supervisor-4.0.0-dev

try to install that from command as follow
>python ./setup.py install
Traceback (most recent call last): file "./setup.py",line 35,in <module> from setuptools import setup,find_packages importError: No module named setuptools

Solution:
https://pypi.python.org/pypi/setuptools#files

>curl https://bootstrap.pypa.io/ez_setup.py -o - | python
>python ./setup.py install

2. Command Arguments in go main
https://gobyexample.com/command-line-arguments
http://golang.org/pkg/os/

First of all,we need to import the os package.
import (
"enCoding/Json"
"fmt"
"github.com/gorilla/mux"
"io/IoUtil"
"net/http"
"os"
)

argsWithProg := os.Args
var port = "8088"
if len(argsWithProg) > 1 {
port = argsWithProg[1]
}
fmt.Println("Start the server on port " + port)
http.ListenAndServe(":"+port,nil)

We get and parse the port number in command line,it both works in go run and bin
>go run src/com/sillycat/easygoapp/restJsonserver.go 8088
>bin/easygoapp 8089

3. Configure the CONF file
http://supervisord.org/configuration.HTML

My configuration file will be as follow /etc/supervisord.conf

[unix_http_server] file = /var/run/supervisord.sock chmod = 0777 #chown= root:root [inet_http_server] # Web管理界面设定 port=9001 username=admin password=admin [supervisorctl] ; 必须和'unix_http_server'里面的设定匹配 serverurl=unix:///var/run/supervisord.sock ;serverurl=http://127.0.0.1:9001 ;username=admin ;password=admin [supervisord] logfile=/var/log/supervisord/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) loglevel=info ; (log level;default info; others: deBUG,warn,trace) pIDfile=/var/run/supervisord.pID ; (supervisord pIDfile;default supervisord.pID) nodaemon=true ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) user=root ; (default is current user,required if root) childlogdir=/var/log/supervisord/ ; ('auto' child log dir,default $TEMP) [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface ; 管理的单个进程的配置,可以添加多个program [program:BUGrest] command=/Users/carl/work/easy/easygo/bin/easygoapp 8089 autostart = true startsecs = 5 user = root redirect_stderr = true stdout_logfile = /var/log/supervisord/BUGrest.log

Start the Server
>sudo supervisord
Error Message
importError: No module named mock

Solution:
>easy_install ipython
>sudo easy_install setuptools
>sudo easy_install mock

>sudo mkdir /var/log/supervisord

Check the Status of my app
>sudo supervisorctl status
BUGrest RUNNING pID 67103,uptime 0:03:08

Then I can use these commands
start BUGrest,restart BUGrest,stop all,reload,stop BUGrest.

The most useful command is this.
>sudo supervisorctl help
default commands (type help <topic>): ===================================== add clear fg open quit remove restart start stop update avail exit maintail pID reload reread shutdown status tail version

>sudo supervisorctl version
4.0.0-dev

References:
https://github.com/astaxIE/build-web-application-with-golang/blob/master/ebook/12.3.md

https://github.com/Supervisor/supervisor
http://supervisord.org/
http://ddbean.wordpress.com/2011/09/16/supervisor-python%E8%BF%9B%E7%A8%8B%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7/

https://pypi.python.org/pypi/setuptools#files

https://gobyexample.com/command-line-arguments

总结

以上是内存溢出为你收集整理的Golang(15)Deployment全部内容,希望文章能够帮你解决Golang(15)Deployment所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1290410.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存