Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ on:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILDKIT_PROGRESS: "plain" # Full logs for CI build.
REGISTRY_URL: "docker.io" # docker.io or other target registry URL: where to push images to.
REGISTRY_SRC: "docker.io" # For BASE_NAMESPACE of images: where to pull base images from.
REGISTRY_SRC: ${{ vars.REGISTRY_SRC || 'docker.io' }} # For BASE_NAMESPACE of images: where to pull base images from, docker.io or other source registry URL.
REGISTRY_DST: ${{ vars.REGISTRY_DST || 'quay.io' }} # For tags of built images: where to push images to, docker.io or other destination registry URL.
# DOCKER_REGISTRY_USERNAME and DOCKER_REGISTRY_PASSWORD is required for docker image push, they should be set in CI secrets.
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_USERNAME: ${{ vars.DOCKER_REGISTRY_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# used to sync image to mirror registry
DOCKER_MIRROR_REGISTRY_USERNAME: ${{ secrets.DOCKER_MIRROR_REGISTRY_USERNAME }}
DOCKER_MIRROR_REGISTRY_USERNAME: ${{ vars.DOCKER_MIRROR_REGISTRY_USERNAME }}
DOCKER_MIRROR_REGISTRY_PASSWORD: ${{ secrets.DOCKER_MIRROR_REGISTRY_PASSWORD }}
CI_PROJECT_NAME: ${{ vars.CI_PROJECT_NAME || 'LabNow/supervisord' }}

jobs:
build_docker_image:
Expand All @@ -37,9 +38,9 @@ jobs:
sed -i -E "s/v[0-9]+\.[0-9]+\.[0-9]+/${VERSION}/" "src/supervisord/version.go"

build_image_no_tag supervisord "alpine-${VER}" src/supervisord.Dockerfile --build-arg "BASE_NAMESPACE=library" --build-arg "BUILD_IMG=golang:alpine" --build-arg "BASE_IMG=alpine"
build_image_no_tag supervisord "ubuntu-${VER}" src/supervisord.Dockerfile --build-arg "BASE_NAMESPACE=qpod" --build-arg "BUILD_IMG=go:latest" --build-arg "BASE_IMG=ubuntu"
docker tag "${IMG_PREFIX}/supervisord:ubuntu-${VER}" "${IMG_PREFIX}/supervisord:ubuntu"
docker tag "${IMG_PREFIX}/supervisord:alpine-${VER}" "${IMG_PREFIX}/supervisord:alpine"
build_image_no_tag supervisord "ubuntu-${VER}" src/supervisord.Dockerfile --build-arg "BASE_NAMESPACE=labnow" --build-arg "BUILD_IMG=go:latest" --build-arg "BASE_IMG=ubuntu"
docker tag "${IMG_PREFIX_DST}/supervisord:ubuntu-${VER}" "${IMG_PREFIX_DST}/supervisord:ubuntu"
docker tag "${IMG_PREFIX_DST}/supervisord:alpine-${VER}" "${IMG_PREFIX_DST}/supervisord:alpine"
push_image supervisord

build_binary:
Expand All @@ -49,7 +50,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
go-version: 1.26
- name: Build Binary
run: |
set -eux
Expand All @@ -72,7 +73,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
go-version: 1.26

- name: Install cross-compiler for linux/arm64, UPX
env:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Go Implementation of Supervisord

[![Go Report Card](https://goreportcard.com/badge/github.com/QPod/supervisord)](https://goreportcard.com/report/github.com/QPod/supervisord)
[![Go Report Card](https://goreportcard.com/badge/github.com/LabNow-ai/supervisord)](https://goreportcard.com/report/github.com/LabNow-ai/supervisord)

## Why this project?

Expand All @@ -10,12 +10,12 @@ This project re-implements supervisord in golang. Compiled `supervisord` has a v

## Download the supervisord binary

You can download the binary of supervisord from the [GitHub Release page](https://github.com/QPod/supervisord/releases/), or use the following command.
You can download the binary of supervisord from the [GitHub Release page](https://github.com/LabNow-ai/supervisord/releases/), or use the following command.

```shell
OS="linux" && ARCH="amd64" \
&& VER_SUPERVISORD=$(curl -sL https://github.com/QPod/supervisord/releases.atom | grep "releases/tag" | head -1 | grep -Po '(\d[\d|.]+)') \
&& URL_SUPERVISORD="https://github.com/QPod/supervisord/releases/download/v${VER_SUPERVISORD}/supervisord_${VER_SUPERVISORD}_${OS}_${ARCH}.tar.gz" \
&& VER_SUPERVISORD=$(curl -sL https://github.com/LabNow-ai/supervisord/releases.atom | grep "releases/tag" | head -1 | grep -Po '(\d[\d|.]+)') \
&& URL_SUPERVISORD="https://github.com/LabNow-ai/supervisord/releases/download/v${VER_SUPERVISORD}/supervisord_${VER_SUPERVISORD}_${OS}_${ARCH}.tar.gz" \
&& echo "Downloading Supervisord ${VER_SUPERVISORD} from ${URL_SUPERVISORD}" \
&& curl -o /tmp/TMP.tgz -sL $URL_SUPERVISORD && tar -C ./ -xzf /tmp/TMP.tgz && rm /tmp/TMP.tgz \
&& ./supervisord version
Expand Down
4 changes: 2 additions & 2 deletions doc/doc-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ syslog_stderr_priority=err

Supervisord has builtin web GUI: you can start, stop & check the status of program from the GUI. Following picture shows the default web GUI:

![screenshot of webui](https://raw.githubusercontent.com/QPod/supervisord/main/doc/go_supervisord_gui.png)
![screenshot of webui](https://raw.githubusercontent.com/LabNow-ai/supervisord/main/doc/go_supervisord_gui.png)

Please note that in order to see|use Web GUI you should configure it in /etc/supervisord.conf both in [inet_http_server] (and|or [unix_http_server] if you prefer unix domain socket) and [supervisorctl]:

Expand All @@ -151,7 +151,7 @@ supervisord is compiled inside a Docker image to be used directly inside another

```Dockerfile
FROM debian:latest
COPY --from=qpod/supervisord:ubuntu /opt/supervisord /opt/supervisord
COPY --from=labnow/supervisord:ubuntu /opt/supervisord /opt/supervisord
CMD ["/opt/supervisord/supervisord"]
```

Expand Down
19 changes: 18 additions & 1 deletion doc/doc-debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,26 @@ docker run --rm -it \
-p 10080:80 \
-v $(pwd):/data \
--entrypoint=/bin/bash \
qpod/supervisord:ubuntu
labnow/supervisord:ubuntu


mkdir -pv /var/log/supervisord
/opt/supervisord/supervisord -c ./supervisord.conf
```

## Replace names and organize imports in code

```bash
function replace_str_in_file() {
local file_path="$1"
local name_pattern="$2"
local str_search="$3"
local str_replace="$4"
# Find all .go files in the target directory recursively
find "${file_path}" -type f \( -name "${name_pattern}" \) | while read -r FILE; do
echo "Replace ${str_search} with ${str_replace} in: $FILE" && sed -i "s/${str_search}/${str_replace}/" "$FILE"
done
}

replace_str_in_file "./" "*.go" "github.com\/ochinchina\/supervisord" "supervisord"
```
6 changes: 3 additions & 3 deletions example/example.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM qpod/openresty
FROM labnow/openresty

WORKDIR /opt/supervisord/

RUN OS="linux" && ARCH="amd64" \
&& VER_SUPERVISORD=$(curl -sL https://github.com/QPod/supervisord/releases.atom | grep "releases/tag" | head -1 | grep -Po '(\d[\d|.]+)') \
&& URL_SUPERVISORD="https://github.com/QPod/supervisord/releases/download/v${VER_SUPERVISORD}/supervisord_${VER_SUPERVISORD}_${OS}_${ARCH}.tar.gz" \
&& VER_SUPERVISORD=$(curl -sL https://github.com/LabNow-ai/supervisord/releases.atom | grep "releases/tag" | head -1 | grep -Po '(\d[\d|.]+)') \
&& URL_SUPERVISORD="https://github.com/LabNow-ai/supervisord/releases/download/v${VER_SUPERVISORD}/supervisord_${VER_SUPERVISORD}_${OS}_${ARCH}.tar.gz" \
&& echo "Downloading Supervisord ${VER_SUPERVISORD} from ${URL_SUPERVISORD}" \
&& curl -o /tmp/TMP.tgz -sL $URL_SUPERVISORD && tar -C ./ -xzf /tmp/TMP.tgz && rm /tmp/TMP.tgz \
&& ./supervisord version
Expand Down
2 changes: 1 addition & 1 deletion src/.goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ snapshot:

release:
github:
owner: QPod
owner: LabNow-ai
name: supervisord
draft: true
prerelease: auto
Expand Down
1 change: 1 addition & 0 deletions src/pidproxy/signal.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

package main
Expand Down
5 changes: 5 additions & 0 deletions src/supervisord/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ func parseEnv(s string) *map[string]string {
for i = start; i < n && s[i] != '='; {
i++
}

if start >= n || i+1 >= n {
break
}

key := s[start:i]
start = i + 1
if s[start] == '"' {
Expand Down
4 changes: 2 additions & 2 deletions src/supervisord/content_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (bc *BaseChecker) Write(b []byte) (int, error) {

func (bc *BaseChecker) isReady() bool {
for _, include := range bc.includes {
if strings.Index(bc.data, include) == -1 {
if !strings.Contains(bc.data, include) {
return false
}
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func (tc *TCPChecker) start() {
b := make([]byte, 1024)
var err error
for {
tc.conn, err = net.Dial("tcp", fmt.Sprintf("%s:%d", tc.host, tc.port))
tc.conn, err = net.Dial("tcp", net.JoinHostPort(tc.host, fmt.Sprintf("%d", tc.port)))
if err == nil || tc.baseChecker.timeoutTime.Before(time.Now()) {
break
}
Expand Down
6 changes: 5 additions & 1 deletion src/supervisord/ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package main

import (
"fmt"
"github.com/jessevdk/go-flags"
"net/http"
"os"
"strings"
"supervisord/config"
"supervisord/types"
"supervisord/xmlrpcclient"

"github.com/jessevdk/go-flags"
)

// CtlCommand the entry of ctl command
Expand Down Expand Up @@ -186,6 +187,7 @@ func (x *CtlCommand) status(rpcc *xmlrpcclient.XMLRPCClient, processes []string)
if reply, err := rpcc.GetAllProcessInfo(); err == nil {
x.showProcessInfo(&reply, processesMap)
} else {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
Expand Down Expand Up @@ -245,6 +247,7 @@ func (x *CtlCommand) shutdown(rpcc *xmlrpcclient.XMLRPCClient) {
fmt.Printf("Hmmm! Something gone wrong?!\n")
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
Expand All @@ -263,6 +266,7 @@ func (x *CtlCommand) reload(rpcc *xmlrpcclient.XMLRPCClient) {
fmt.Printf("Removed Groups: %s\n", strings.Join(reply.RemovedGroup, ","))
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/supervisord/logtail.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (lt *Logtail) getLog(logType string, w http.ResponseWriter, req *http.Reque
return
}

var ok = false
var ok bool = false
var compositeLogger *logger.CompositeLogger = nil
if logType == "stdout" {
compositeLogger, ok = proc.StdoutLog.(*logger.CompositeLogger)
Expand Down
13 changes: 10 additions & 3 deletions src/supervisord/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import (
"syscall"
"unicode"

"supervisord/config"
"supervisord/logger"

"github.com/jessevdk/go-flags"
"github.com/ochinchina/go-ini"
log "github.com/sirupsen/logrus"
"supervisord/config"
"supervisord/logger"
)

var BuildVersion string = ""

// Options the command line options
type Options struct {
Configuration string `short:"c" long:"configuration" description:"the configuration file"`
Expand Down Expand Up @@ -111,7 +114,8 @@ func findSupervisordConf() (string, error) {
"/etc/supervisord.conf",
"/etc/supervisor/supervisord.conf",
"../etc/supervisord.conf",
"../supervisord.conf"}
"../supervisord.conf",
"./supervisord.conf"}

for _, file := range possibleSupervisordConf {
if _, err := os.Stat(file); err == nil {
Expand Down Expand Up @@ -162,6 +166,9 @@ func getSupervisordLogFile(configFile string) string {
}

func main() {
if BuildVersion != "" {
VERSION = BuildVersion
}
ReapZombie()

// when execute `supervisord` without sub-command, it should start the server
Expand Down
Loading