Categorygithub.com/webtor-io/common-services
repositorypackage
0.0.0-20250112153432-554128b56bd5
Repository: https://github.com/webtor-io/common-services.git
Documentation: pkg.go.dev

# README

common-services

Collection of commonly used services at webtor.io

Probe

Generates standard liveness and readiness probe endpoints for kubernetes

Serve

Runs simultaneously multiple services in goroutines

Example usage

package main

import (
	cs "github.com/webtor-io/common-services"
	log "github.com/sirupsen/logrus"
	"github.com/urfave/cli"
	s "github.com/webtor-io/torrent-http-proxy/services"
)

func configure(app *cli.App) {
	app.Flags = []cli.Flag{}

	s.RegisterWebFlags(app)
	cs.RegisterProbeFlags(app)

	app.Action = run
}

func run(c *cli.Context) error {
	// Setting ProbeService
	probe := cs.NewProbe(c)
	defer probe.Close()

	// Setting WebService
	web := s.NewWeb(c)
	defer web.Close()

	// Setting ServeService
	serve := cs.NewServe(probe, web)

	// And SERVE!
	err := serve.Serve()
	if err != nil {
		log.WithError(err).Error("Got serve error")
	}
	return err
}