优化配置
This commit is contained in:
		
							parent
							
								
									00d17dedf7
								
							
						
					
					
						commit
						4205453007
					
				
							
								
								
									
										13
									
								
								Dockerfile
								
								
								
								
							
							
						
						
									
										13
									
								
								Dockerfile
								
								
								
								
							|  | @ -1,15 +1,12 @@ | ||||||
| FROM registry.cn-chengdu.aliyuncs.com/lansexiongdi/work:v1 | FROM ubuntu | ||||||
|  | ENV TZ=Asia/Shanghai | ||||||
|  | ENV LANG=C.UTF-8 | ||||||
|  | ENV SERVER=api | ||||||
| 
 | 
 | ||||||
| RUN echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/main' > /etc/apk/repositories \ |  | ||||||
| && echo 'http://mirrors.ustc.edu.cn/alpine/v3.5/community' >>/etc/apk/repositories \ |  | ||||||
| && apk update && apk add tzdata \ |  | ||||||
| && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ |  | ||||||
| && echo "Asia/Shanghai" > /etc/timezone |  | ||||||
| 
 |  | ||||||
| ARG APP_RELATIVE_PATH |  | ||||||
| 
 | 
 | ||||||
| WORKDIR /app | WORKDIR /app | ||||||
| COPY  ./server /app | COPY  ./server /app | ||||||
|  | COPY ./.env /app/.env | ||||||
| EXPOSE 8000 | EXPOSE 8000 | ||||||
| 
 | 
 | ||||||
| CMD ["./server"] | CMD ["./server"] | ||||||
							
								
								
									
										26
									
								
								main.go
								
								
								
								
							
							
						
						
									
										26
									
								
								main.go
								
								
								
								
							|  | @ -2,7 +2,6 @@ package main | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
| 	"flag" |  | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	_ "github.com/go-sql-driver/mysql" | 	_ "github.com/go-sql-driver/mysql" | ||||||
| 	_ "github.com/qit-team/snow-core/cache/rediscache" | 	_ "github.com/qit-team/snow-core/cache/rediscache" | ||||||
|  | @ -60,26 +59,8 @@ import ( | ||||||
| // @authorizationUrl https://example.com/oauth/authorize
 | // @authorizationUrl https://example.com/oauth/authorize
 | ||||||
| // @scope.admin Grants read and write access to administrative information
 | // @scope.admin Grants read and write access to administrative information
 | ||||||
| 
 | 
 | ||||||
| var ( |  | ||||||
| 	port  string |  | ||||||
| 	kafka string |  | ||||||
| 	num   int |  | ||||||
| 	url   string |  | ||||||
| 	group string |  | ||||||
| 	topic string |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func initConfig() { |  | ||||||
| 	flag.StringVar(&kafka, "kafka", "", "kafka url") |  | ||||||
| 	flag.StringVar(&port, "port", "9502", "tcp port") |  | ||||||
| 	flag.IntVar(&num, "num", 10, "进程数量") |  | ||||||
| 	flag.StringVar(&url, "url", "", "内网地址") |  | ||||||
| 	flag.StringVar(&group, "group", "", "消费分组") |  | ||||||
| 	flag.StringVar(&topic, "topic", "", "消费topic") |  | ||||||
| } |  | ||||||
| func main() { | func main() { | ||||||
| 	//解析启动命令
 | 	//解析启动命令
 | ||||||
| 	initConfig() |  | ||||||
| 	opts := config.GetOptions() | 	opts := config.GetOptions() | ||||||
| 	if opts.ShowVersion { | 	if opts.ShowVersion { | ||||||
| 		fmt.Printf("%s\ncommit %s\nbuilt on %s\n", server.Version, server.BuildCommit, server.BuildDate) | 		fmt.Printf("%s\ncommit %s\nbuilt on %s\n", server.Version, server.BuildCommit, server.BuildDate) | ||||||
|  | @ -123,13 +104,6 @@ func startServer(opts *config.Options) (err error) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	pidFile := opts.GenPidFile() | 	pidFile := opts.GenPidFile() | ||||||
| 	config.GetConf().KafkaUrl = kafka |  | ||||||
| 	config.GetConf().OrderPort = port |  | ||||||
| 	config.GetConf().Num = num |  | ||||||
| 	config.GetConf().Url = url |  | ||||||
| 	config.GetConf().KafkaGroup = group |  | ||||||
| 	config.GetConf().Topical = topic |  | ||||||
| 	fmt.Println(port, kafka, num) |  | ||||||
| 	//根据启动命令行参数,决定启动哪种服务模式
 | 	//根据启动命令行参数,决定启动哪种服务模式
 | ||||||
| 	switch opts.App { | 	switch opts.App { | ||||||
| 	case "api": | 	case "api": | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue