• This repository has been archived on 31/Mar/2023
  • Stars
    star
    125
  • Rank 286,335 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go framework for well-behaving commands

GitHub release CI PkgGoDev Go Report Card

Go Command Framework

Deprecated: This project has come to an end and will not receive any update.

This is a framework to create well-behaving commands.

Features

Requirements

Go 1.11 or later, though the code is expected to work with Go 1.7.

Specifications

Commands using this framework implement these external specifications:

Command-line options

  • -logfile FILE

    Output logs to FILE instead of standard error.

  • -loglevel LEVEL

    Change logging threshold to LEVEL. Default is info.
    LEVEL is one of critical, error, warning, info, or debug.

  • -logformat FORMAT

    Change log formatter. Default is plain.
    FORMAT is one of plain, logfmt, or json.

Signal Handlers

  • SIGUSR1

    If -logfile is specified, this signal make the program reopen the log file to cooperate with an external log rotation program.

    On Windows, this is not implemented.

  • SIGINT and SIGTERM

    These signals cancel the context of the global environment, and hence goroutines registered with the environment. Usually this will result in graceful stop of network servers, if any.

    On Windows, only SIGINT is handled.

  • SIGHUP

    This signal is used to restart network servers gracefully. Internally, the main (master) process restarts its child process. The PID of the master process thus will not change.

    There is one limitation: the location of log file cannot be changed by graceful restart. To change log file location, the server need to be (gracefully) stopped and started.

    On Windows, this is not implemented.

  • SIGPIPE

    The framework changes the way Go handles SIGPIPE slightly. If a program using this framework receives SIGPIPE when writing to stdout or stderr, the program exits with status code 2. See #15 for details.

Environment variables

  • REQUEST_ID_HEADER

    The value of this variable is used as HTTP header name. The HTTP header is used to track activities across services. The default header name is "X-Cybozu-Request-ID".

  • CYBOZU_LISTEN_FDS

    This is used internally for graceful restart.

  • CANCELLATION_DELAY_SECONDS

    After SIGINT or SIGTERM received, the signal handler waits for the seconds before cancelling the context. The default value is 5 sec.

Usage

Read Tutorial, the design notes and API documents.

A wiki page for cobra users is also available.

Real world examples

Pull requests are welcome to add your project to this list!

More Repositories

1

transocks

Transparent SOCKS5 / HTTP proxy in Go
Go
465
star
2

moco

MySQL operator on Kubernetes using GTID-based semi-synchronous replication.
Go
246
star
3

neco

Project Neco
Go
241
star
4

cke

Cybozu Kubernetes Engine
Go
193
star
5

coil

CNI plugin for Kubernetes designed for scalability and extensibility
Go
164
star
6

usocksd

SOCKS4/5 server library and command in Go
Go
142
star
7

goma

An extensible monitoring agent in Go.
Go
124
star
8

aptutil

Go utilities for Debian APT repositories
Go
123
star
9

sabakan

A versatile network boot server for large data centers
Go
122
star
10

placemat

Virtual data center construction tool
Go
82
star
11

etcdpasswd

Distributed Linux user management using etcd
Go
46
star
12

accurate

Kubernetes controller for multi-tenancy. It propagates resources between namespaces accurately and allows tenant users to create/delete sub-namespaces.
Go
28
star
13

log

Logging framework for Cybozu Go products
Go
28
star
14

contour-plus

Enhance contour for external-dns and cert-manager
Go
25
star
15

meows

Kubernetes controller for GitHub actions self-hosted runners
Go
19
star
16

netutil

Add-ons for Go networking
Go
17
star
17

kkok

Alert routing and filtering service
Go
10
star
18

scim

generic SCIM server/client library in Go
Go
7
star
19

options

A small library that provides Option[T], which represents an optional value of type T
Go
5
star
20

cat-gate

A Kubernetes controller to delay pod deployment using scheduling gates
Go
5
star
21

setup-hw

Build container image to configure BMC and BIOS
Go
5
star
22

nginx-i2c

ip2country.conf generation tool for nginx
Go
4
star
23

scim-server

Go
4
star
24

pod-security-admission

A Kubernetes admission webhook to ensure pod security standards
Go
4
star
25

nyamber

Custom controllers to create Neco environment
Go
1
star
26

neco-template

Template repository for Neco
Makefile
1
star
27

neco-gcp

GCP management tools for project Neco
Go
1
star
28

necotiator

ResourceQuota Controller for soft multi-tenancy
Go
1
star
29

etcdutil

Add-ons for etcd
Go
1
star
30

cattage

Kubernetes controller that enhances the multi-tenancy of Argo CD with Accurate.
Go
1
star
31

tenet

Tenet is a Kubernetes controller that aims to facilitate setting-up Network Policies on tenant namespaces.
Go
1
star
32

necoperf

necoperf provides the ability to easily retrieve profiles of containers running on Kubernetes.
Go
1
star
33

zombie-detector

Go
1
star