zoukankan      html  css  js  c++  java
  • supervisord golang 实现试用

    supervisord 有一个golang 的实现,而且功能很强大,使用和python 版的基本一样
    以下是一个简单的试用

    环境准备

    • 项目
      简单golang demo
     
    go mod github.com/rongfengliang/restapi
    go get github.com/gin-gonic/gin
    main.go
    package main
    import "github.com/gin-gonic/gin"
    func main() {
        r := gin.Default()
        r.GET("/", func(context *gin.Context) {
            context.String(200, "ok")
        })
        r.Run(":8080")
    }

    Dockerfile

    FROM golang:1.13-alpine AS build-env
    WORKDIR /go/src/app
    RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
    ENV  GO111MODULE=on
    ENV  GOPROXY=https://goproxy.cn
    COPY . .
    RUN apk update && apk add git 
        && go build -o rest-api
    FROM alpine:latest
    WORKDIR /app
    RUN  /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories
    RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
    COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
    COPY --from=build-env /go/src/app/rest-api /app/rest-api
    COPY supervisor.conf /etc/supervisord.conf
    EXPOSE 8080
    CMD ["/usr/local/bin/supervisord"]
    • docker-compose 文件
    version: "3"
    services: 
       api: 
         build: ./
         image: dalongrong/golang-supervisord
         ports: 
         - "8080:8080"
     
     
    • supervisor 配置
      supervisor.conf
     
    [program:restapi]
    command = /app/rest-api
    [inet_http_server]
    port = :9001

    启动&&效果

    • 构建镜像
    docker-compose build
    • 启动
    docker-compose up -d
    • 效果

    restapi


    管理ui

    说明

    supervisord 是一个不错的python 版本替换,轻量,简单,比较适合容器应用,同时也支持依赖管理

    参考资料

    https://github.com/ochinchina/supervisord
    https://github.com/rongfengliang/golang-supervisord-learning

  • 相关阅读:
    进程DLL注入
    静态链接库LIB
    利用MoveFileEx实现程序的隐藏、自启动与自删除
    QueueUserApc实现DLL注入的测试
    简单说说SSDT
    ural 1521. War Games 2 约瑟夫环 SBT实现
    次小生成树 (附:poj1679)
    hoj 1138 LC Display
    hoj 3029 Dictionary 模拟队列
    hoj 2578 Super_Stack 模拟栈
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/13082834.html
Copyright © 2011-2022 走看看