Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change references and bump dependencies #2

Merged
merged 11 commits into from
Sep 11, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ name: CI

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: 1.22

- name: Build
run: go build -v ./...
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
time: "12:00"
open-pull-requests-limit: 10
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:alpine AS builder
FROM golang:1.22-alpine3.20 AS builder

RUN apk add --no-cache --update git gcc rust

COPY . /src
WORKDIR /src

RUN CGO_ENABLED=0 go build -a -ldflags "-linkmode external -extldflags -static" -o /usr/local/bin/supervisord github.com/ochinchina/supervisord
RUN CGO_ENABLED=0 go build -a -ldflags "-linkmode external -extldflags -static" -o /usr/local/bin/supervisord github.com/cyralinc/supervisord

FROM scratch

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.github
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#
# Build with:
#
# docker build . -f Dockerfile.github -t ochinchina/supervisord:latest
# docker build . -f Dockerfile.github -t cyralinc/supervisord:latest
#
FROM golang:alpine as builder
FROM golang:1.22-alpine3.20 AS builder

RUN apk add --no-cache --update git

Expand All @@ -14,9 +14,9 @@ RUN mkdir -p $GOPATH/src/golang.org/x && \
git clone https://github.com/golang/sys

# Exit 0 to ignore meta tag complaints
RUN go get -v -u github.com/ochinchina/supervisord; exit 0
RUN go get -v -u github.com/cyralinc/supervisord; exit 0

RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags -static" -o /usr/local/bin/supervisord github.com/ochinchina/supervisord
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags -static" -o /usr/local/bin/supervisord github.com/cyralinc/supervisord

FROM scratch

Expand Down
122 changes: 64 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/ochinchina/supervisord)](https://goreportcard.com/report/github.com/ochinchina/supervisord)
[![Go Report Card](https://goreportcard.com/badge/github.com/cyralinc/supervisord)](https://goreportcard.com/report/github.com/cyralinc/supervisord)

# Why this project?

Expand All @@ -8,20 +8,26 @@ But this tool requires that the big python environment be installed in target sy

This project re-implements supervisord in go-lang. Compiled supervisord is very suitable for environments where python is not installed.

# Why we forked it?

The original project hasn't been actively maintained for one year at the time we forked it. We need to keep it up-to-date and eventually change some things, so why not fork it? :-)

# Building the supervisord

Before compiling the supervisord, make sure the go-lang 1.11+ is installed in your environment.
Before compiling the supervisord, make sure the go-lang 1.22 is installed in your environment.

To compile supervisord for **linux**, run following commands:

1. go generate
2. GOOS=linux go build -tags release -a -ldflags "-linkmode external -extldflags -static" -o supervisord
```shell
go generate
GOOS=linux go build -tags release -a -ldflags "-linkmode external -extldflags -static" -o supervisord
```

# Run the supervisord

After a supervisord binary has been generated, create a supervisord configuration file and start the supervisord like this:

```Shell
```shell
$ cat supervisor.conf
[program:test]
command = /your/program args
Expand Down Expand Up @@ -73,7 +79,7 @@ $ supervisord ctl pid <process_name>
$ supervisord ctl fg <process_name>
```

Please note that `supervisor ctl` subcommand works correctly only if http server is enabled in [inet_http_server], and **serverurl** correctly set. Unix domain socket is not currently supported for this pupose.
Please note that `supervisor ctl` subcommand works correctly only if http server is enabled in [inet_http_server], and `serverurl` correctly set. Unix domain socket is not currently supported for this pupose.

Serverurl parameter detected in the following order:

Expand Down Expand Up @@ -105,53 +111,53 @@ If both "inet_http_server" and "unix_http_server" are not set up in the configur

Following parameters configured in "supervisord" section:

- **logfile**. Where to put log of supervisord itself.
- **logfile_maxbytes**. Rotate log-file after it exceeds this length.
- **logfile_backups**. Number of rotated log-files to preserve.
- **loglevel**. Logging verbosity, can be trace, debug, info, warning, error, fatal and panic (according to documentation of module used for this feature). Defaults to info.
- **pidfile**. Full path to file containing process id of current supervisord instance.
- **minfds**. Reserve al least this amount of file descriptors on supervisord startup. (Rlimit nofiles).
- **minprocs**. Reserve at least this amount of processes resource on supervisord startup. (Rlimit noproc).
- **identifier**. Identifier of this supervisord instance. Required if there is more than one supervisord run on one machine in same namespace.
- `logfile`: Where to put log of supervisord itself.
- `logfile_maxbytes`: Rotate log-file after it exceeds this length.
- `logfile_backups`: Number of rotated log-files to preserve.
- `loglevel`: Logging verbosity, can be trace, debug, info, warning, error, fatal and panic (according to documentation of module used for this feature). Defaults to info.
- `pidfile`: Full path to file containing process id of current supervisord instance.
- `minfds`: Reserve al least this amount of file descriptors on supervisord startup. (Rlimit nofiles).
- `minprocs`: Reserve at least this amount of processes resource on supervisord startup. (Rlimit noproc).
- `identifier`: Identifier of this supervisord instance. Required if there is more than one supervisord run on one machine in same namespace.

## Supervised program settings

Supervised program settings configured in [program:programName] section and include these options:

- **command**. Command to supervise. It can be given as full path to executable or can be calculated via PATH variable. Command line parameters also should be supplied in this string.
- **process_name**. the process name
- **numprocs**. number of process
- **numprocs_start**. ??
- **autostart**. Should be supervised command run on supervisord start? Defaults to **true**.
- **startsecs**. The total number of seconds which the program needs to stay running after a startup to consider the start successful (moving the process from the STARTING state to the RUNNING state). Set to 0 to indicate that the program needn’t stay running for any particular amount of time.
- **startretries**. The number of serial failure attempts that supervisord will allow when attempting to start the program before giving up and putting the process into an FATAL state. See Process States for explanation of the FATAL state.
- **autorestart**. Automatically re-run supervised command if it dies.
- **exitcodes**. The list of “expected” exit codes for this program used with autorestart. If the autorestart parameter is set to unexpected, and the process exits in any other way than as a result of a supervisor stop request, supervisord will restart the process if it exits with an exit code that is not defined in this list.
- **stopsignal**. Signal to send to command to gracefully stop it. If more than one stopsignal is configured, when stoping the program, the supervisor will send the signals to the program one by one with interval "stopwaitsecs". If the program does not exit after all the signals sent to the program, supervisord will kill the program.
- **stopwaitsecs**. Amount of time to wait before sending SIGKILL to supervised command to make it stop ungracefully.
- **stdout_logfile**. Where STDOUT of supervised command should be redirected. (Particular values described lower in this file).
- **stdout_logfile_maxbytes**. Log size after exceed which log will be rotated.
- **stdout_logfile_backups**. Number of rotated log-files to preserve.
- **redirect_stderr**. Should STDERR be redirected to STDOUT.
- **stderr_logfile**. Where STDERR of supervised command should be redirected. (Particular values described lower in this file).
- **stderr_logfile_maxbytes**. Log size after exceed which log will be rotated.
- **stderr_logfile_backups**. Number of rotated log-files to preserve.
- **environment**. List of VARIABLE=value to be passed to supervised program. It has higher priority than `envFiles`.
- **envFiles**. List of .env files to be loaded and passed to supervised program.
- **priority**. The relative priority of the program in the start and shutdown ordering
- **user**. Sudo to this USER or USER:GROUP right before exec supervised command.
- **directory**. Jump to this path and exec supervised command there.
- **stopasgroup**. Also stop this program when stopping group of programs where this program is listed.
- **killasgroup**. Also kill this program when stopping group of programs where this program is listed.
- **restartpause**. Wait (at least) this amount of seconds after stpping suprevised program before strt it again.
- **restart_when_binary_changed**. Boolean value (false or true) to control if the supervised command should be restarted when its executable binary changes. Defaults to false.
- **restart_cmd_when_binary_changed**. The command to restart the program if the program binary itself is changed.
- **restart_signal_when_binary_changed**. The signal sent to the program for restarting if the program binary is changed.
- **restart_directory_monitor**. Path to be monitored for restarting purpose.
- **restart_file_pattern**. If a file changes under restart_directory_monitor and filename matches this pattern, the supervised command will be restarted.
- **restart_cmd_when_file_changed**. The command to restart the program if any monitored files under **restart_directory_monitor** with pattern **restart_file_pattern** are changed.
- **restart_signal_when_file_changed**. The signal will be sent to the proram, such as Nginx, for restarting if any monitored files under **restart_directory_monitor** with pattern **restart_file_pattern** are changed.
- **depends_on**. Define supervised command start dependency. If program A depends on program B, C, the program B, C will be started before program A. Example:
- `command`: Command to supervise. It can be given as full path to executable or can be calculated via PATH variable. Command line parameters also should be supplied in this string.
- `process_name`: the process name
- `numprocs`: number of process
- `numprocs_start`: ??
- `autostart`: Should be supervised command run on supervisord start? Defaults to `true`.
- `startsecs`: The total number of seconds which the program needs to stay running after a startup to consider the start successful (moving the process from the STARTING state to the RUNNING state). Set to 0 to indicate that the program needn’t stay running for any particular amount of time.
- `startretries`: The number of serial failure attempts that supervisord will allow when attempting to start the program before giving up and putting the process into an FATAL state. See Process States for explanation of the FATAL state.
- `autorestart`: Automatically re-run supervised command if it dies.
- `exitcodes`: The list of “expected” exit codes for this program used with autorestart. If the autorestart parameter is set to unexpected, and the process exits in any other way than as a result of a supervisor stop request, supervisord will restart the process if it exits with an exit code that is not defined in this list.
- `stopsignal`: Signal to send to command to gracefully stop it. If more than one stopsignal is configured, when stoping the program, the supervisor will send the signals to the program one by one with interval "stopwaitsecs". If the program does not exit after all the signals sent to the program, supervisord will kill the program.
- `stopwaitsecs`: Amount of time to wait before sending SIGKILL to supervised command to make it stop ungracefully.
- `stdout_logfile`: Where STDOUT of supervised command should be redirected. (Particular values described lower in this file).
- `stdout_logfile_maxbytes`: Log size after exceed which log will be rotated.
- `stdout_logfile_backups`: Number of rotated log-files to preserve.
- `redirect_stderr`: Should STDERR be redirected to STDOUT.
- `stderr_logfile`: Where STDERR of supervised command should be redirected. (Particular values described lower in this file).
- `stderr_logfile_maxbytes`: Log size after exceed which log will be rotated.
- `stderr_logfile_backups`: Number of rotated log-files to preserve.
- `environment`: List of VARIABLE=value to be passed to supervised program. It has higher priority than `envFiles`.
- `envFiles`: List of .env files to be loaded and passed to supervised program.
- `priority`: The relative priority of the program in the start and shutdown ordering
- `user`: Sudo to this USER or USER:GROUP right before exec supervised command.
- `directory`: Jump to this path and exec supervised command there.
- `stopasgroup`: Also stop this program when stopping group of programs where this program is listed.
- `killasgroup`: Also kill this program when stopping group of programs where this program is listed.
- `restartpause`: Wait (at least) this amount of seconds after stpping suprevised program before strt it again.
- `restart_when_binary_changed`: Boolean value (false or true) to control if the supervised command should be restarted when its executable binary changes. Defaults to false.
- `restart_cmd_when_binary_changed`: The command to restart the program if the program binary itself is changed.
- `restart_signal_when_binary_changed`: The signal sent to the program for restarting if the program binary is changed.
- `restart_directory_monitor`: Path to be monitored for restarting purpose.
- `restart_file_pattern`: If a file changes under restart_directory_monitor and filename matches this pattern, the supervised command will be restarted.
- `restart_cmd_when_file_changed`: The command to restart the program if any monitored files under `restart_directory_monitor` with pattern `restart_file_pattern` are changed.
- `restart_signal_when_file_changed`: The signal will be sent to the proram, such as Nginx, for restarting if any monitored files under `restart_directory_monitor` with pattern `restart_file_pattern` are changed.
- `depends_on`: Define supervised command start dependency. If program A depends on program B, C, the program B, C will be started before program A. Example:

```ini
[program:A]
Expand Down Expand Up @@ -200,12 +206,12 @@ Supervisord 3.x defined events are supported partially. Now it supports followin

Supervisord can redirect stdout and stderr ( fields stdout_logfile, stderr_logfile ) of supervised programs to:

- **/dev/null**. Ignore the log - send it to /dev/null.
- **/dev/stdout**. Write log to STDOUT.
- **/dev/stderr**. Write log to STDERR.
- **syslog**. Send the log to local syslog service.
- **syslog @[protocol:]host[:port]**. Send log events to remote syslog server. Protocol must be "tcp" or "udp", if missing, "udp" assumed. If port is missing, for "udp" protocol, it's defaults to 514 and for "tcp" protocol, it's value is 6514.
- **file name**. Write log to specified file.
- `/dev/null`: Ignore the log - send it to /dev/null.
- `/dev/stdout`: Write log to STDOUT.
- `/dev/stderr`: Write log to STDERR.
- `syslog`: Send the log to local syslog service.
- `syslog @[protocol:]host[:port]`: Send log events to remote syslog server. Protocol must be "tcp" or "udp", if missing, "udp" assumed. If port is missing, for "udp" protocol, it's defaults to 514 and for "tcp" protocol, it's value is 6514.
- `file name`: Write log to specified file.

Multiple log files can be configured for the stdout_logfile and stderr_logfile with ',' as delimiter. For example:

Expand All @@ -222,16 +228,16 @@ syslog_tag=test
syslog_stdout_priority=info
syslog_stderr_priority=err
```
- **syslog_facility**, can be one of(case insensitive): KERNEL, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0~LOCAL7
- **syslog_stdout_priority**, can be one of(case insensitive): EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
- **syslog_stderr_priority**, can be one of(case insensitive): EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
- `syslog_facility`, can be one of(case insensitive): KERNEL, USER, MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, LOCAL0~LOCAL7
- `syslog_stdout_priority`, can be one of(case insensitive): EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG
- `syslog_stderr_priority`, can be one of(case insensitive): EMERG, ALERT, CRIT, ERR, WARN, NOTICE, INFO, DEBUG


# Web GUI

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

![alt text](https://github.com/ochinchina/supervisord/blob/master/go_supervisord_gui.png)
![alt text](https://github.com/cyralinc/supervisord/blob/master/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 Down
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
deployment:
master:
branch: [master]
main:
branch: [main]
commands:
- go version
- go get github.com/mitchellh/gox
Expand Down
10 changes: 8 additions & 2 deletions config/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module github.com/ochinchina/supervisord/config
module github.com/cyralinc/supervisord/config

go 1.16
go 1.22

require (
github.com/hashicorp/go-envparse v0.1.0
github.com/ochinchina/go-ini v1.0.1
github.com/ochinchina/supervisord/util v0.0.0-20230902082938-c2cae38b7454
github.com/sirupsen/logrus v1.8.1
)

require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect

replace github.com/ochinchina/supervisord/util => ../util
2 changes: 2 additions & 0 deletions config/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdmPSDFPY=
github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc=
github.com/ochinchina/go-ini v1.0.1 h1:qrKGrgxJjY+4H8aV7B2HPohShzHGrymW+/X1Gx933zU=
github.com/ochinchina/go-ini v1.0.1/go.mod h1:Tqs5+JmccLSNMX1KXbbyG/B3ro4J9uXVYC5U5VOeRE8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
6 changes: 4 additions & 2 deletions events/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/ochinchina/supervisord/events
module github.com/cyralinc/supervisord/events

go 1.16
go 1.22

require github.com/sirupsen/logrus v1.8.1

require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
7 changes: 4 additions & 3 deletions faults/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/ochinchina/supervisord/faults
module github.com/cyralinc/supervisord/faults

go 1.16
go 1.22

require github.com/ochinchina/gorilla-xmlrpc v0.0.0-20171012055324-ecf2fe693a2c

require (
github.com/gorilla/rpc v1.2.0 // indirect
github.com/ochinchina/gorilla-xmlrpc v0.0.0-20171012055324-ecf2fe693a2c
github.com/rogpeppe/go-charset v0.0.0-20190617161244-0dc95cdf6f31 // indirect
)
Loading