server

package
v0.0.0-...-1090150 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Resource embed.FS

*************************************************** * Embed Resources /***************************************************

Functions

func DelJobHandler

func DelJobHandler(c *gin.Context)

func EmbedFileSystem

func EmbedFileSystem(fs http.FileSystem) *embedFileSystem

func GetConfigHandler

func GetConfigHandler(c *gin.Context)

GetConfigHandler will serve config file

func GetJobHandler

func GetJobHandler(c *gin.Context)

GetConfigHandler will serve config file

func GetLatestLogHandler

func GetLatestLogHandler(c *gin.Context)

GetLatestLogHandler

func GetLogHandler

func GetLogHandler(c *gin.Context)

Get log by job id

func InitDefaultServer

func InitDefaultServer(listenAddr, configPath, dataDir, publicDir string)

InitDefaultServer will init default pigsty singleton

func ListJobHandler

func ListJobHandler(c *gin.Context)

ListJobHandler will serve config file

func ListLogHandler

func ListLogHandler(c *gin.Context)

ListLogHandler will iter log directory and return log(job) list

func MakeDataDir

func MakeDataDir(path string) error

*************************************************** * Log Info /*************************************************** MakeDataDir will make sure data dir exists

func PostConfigHandler

func PostConfigHandler(c *gin.Context)

PostConfigHandler will update default configuration file with posted content TODO: convenient but dangerous!!!

func PostJobHandler

func PostJobHandler(c *gin.Context)

PostJobHandler will create new job

Types

type LogInfo

type LogInfo struct {
	Name  string `json:"name"`
	Size  int64  `json:"size"`
	Mtime int64  `json:"mtime"`
}

LogInfo Hold log name, size, mtime info of job logs

type PigstyServer

type PigstyServer struct {
	ListenAddr string
	ConfigPath string
	DataDir    string
	PublicDir  string
	HomeDir    string
	Server     *http.Server
	Executor   *exec.Executor
	Job        *exec.Job // shitty-implementation: only one job allow one time
	// contains filtered or unexported fields
}

PigstyServer holds required information

var PS *PigstyServer

*************************************************** * Pigsty Server /*************************************************** PS is the default PigstyServer

func NewPigstyServer

func NewPigstyServer(opts ...ServerOpt) *PigstyServer

NewPigstyServer will create new server

func (*PigstyServer) DefaultRouter

func (ps *PigstyServer) DefaultRouter() *gin.Engine

func (*PigstyServer) DelJob

func (ps *PigstyServer) DelJob() *exec.Job

CancelJob will cancel current job

func (*PigstyServer) GetJob

func (ps *PigstyServer) GetJob() *exec.Job

Get Job will return current running job, nil if not exists

func (*PigstyServer) JobDir

func (ps *PigstyServer) JobDir() string

func (*PigstyServer) JobPath

func (ps *PigstyServer) JobPath(name string) string

func (*PigstyServer) LisJobDir

func (ps *PigstyServer) LisJobDir() ([]exec.Job, error)

func (*PigstyServer) ListLogDir

func (ps *PigstyServer) ListLogDir() ([]LogInfo, error)

ListLogdir will return

func (*PigstyServer) LoadJob

func (ps *PigstyServer) LoadJob(id string) *exec.Job

func (*PigstyServer) LogDir

func (ps *PigstyServer) LogDir() string

func (*PigstyServer) LogPath

func (ps *PigstyServer) LogPath(name string) string

func (*PigstyServer) Reload

func (ps *PigstyServer) Reload(configPath string) error

Reload will create a new Executor according to config

func (*PigstyServer) Run

func (ps *PigstyServer) Run()

run will launch server and listen

func (*PigstyServer) RunJob

func (ps *PigstyServer) RunJob(job *exec.Job) (*exec.Job, error)

RunJob will run job on background, error if running job already exists

func (*PigstyServer) SaveJob

func (ps *PigstyServer) SaveJob(job *exec.Job) error

type ServerOpt

type ServerOpt func(server *PigstyServer)

ServerOpt will configure pigsty server

func WithConfigPath

func WithConfigPath(configPath string) ServerOpt

func WithDataDir

func WithDataDir(dataDir string) ServerOpt

func WithListenAddress

func WithListenAddress(listenAddr string) ServerOpt

WithStdout will set stdout

func WithPublicDir

func WithPublicDir(publicDir string) ServerOpt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL