Documentation ¶
Index ¶
- Variables
- func DelJobHandler(c *gin.Context)
- func EmbedFileSystem(fs http.FileSystem) *embedFileSystem
- func GetConfigHandler(c *gin.Context)
- func GetJobHandler(c *gin.Context)
- func GetLatestLogHandler(c *gin.Context)
- func GetLogHandler(c *gin.Context)
- func InitDefaultServer(listenAddr, configPath, dataDir, publicDir string)
- func ListJobHandler(c *gin.Context)
- func ListLogHandler(c *gin.Context)
- func MakeDataDir(path string) error
- func PostConfigHandler(c *gin.Context)
- func PostJobHandler(c *gin.Context)
- type LogInfo
- type PigstyServer
- func (ps *PigstyServer) DefaultRouter() *gin.Engine
- func (ps *PigstyServer) DelJob() *exec.Job
- func (ps *PigstyServer) GetJob() *exec.Job
- func (ps *PigstyServer) JobDir() string
- func (ps *PigstyServer) JobPath(name string) string
- func (ps *PigstyServer) LisJobDir() ([]exec.Job, error)
- func (ps *PigstyServer) ListLogDir() ([]LogInfo, error)
- func (ps *PigstyServer) LoadJob(id string) *exec.Job
- func (ps *PigstyServer) LogDir() string
- func (ps *PigstyServer) LogPath(name string) string
- func (ps *PigstyServer) Reload(configPath string) error
- func (ps *PigstyServer) Run()
- func (ps *PigstyServer) RunJob(job *exec.Job) (*exec.Job, error)
- func (ps *PigstyServer) SaveJob(job *exec.Job) error
- type ServerOpt
Constants ¶
This section is empty.
Variables ¶
var Resource embed.FS
*************************************************** * Embed Resources /***************************************************
Functions ¶
func DelJobHandler ¶
func EmbedFileSystem ¶
func EmbedFileSystem(fs http.FileSystem) *embedFileSystem
func GetConfigHandler ¶
GetConfigHandler will serve config file
func InitDefaultServer ¶
func InitDefaultServer(listenAddr, configPath, dataDir, publicDir string)
InitDefaultServer will init default pigsty singleton
func ListLogHandler ¶
ListLogHandler will iter log directory and return log(job) list
func MakeDataDir ¶
*************************************************** * Log Info /*************************************************** MakeDataDir will make sure data dir exists
func PostConfigHandler ¶
PostConfigHandler will update default configuration file with posted content TODO: convenient but dangerous!!!
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) ListLogDir ¶
func (ps *PigstyServer) ListLogDir() ([]LogInfo, error)
ListLogdir will return
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
type ServerOpt ¶
type ServerOpt func(server *PigstyServer)
ServerOpt will configure pigsty server
func WithConfigPath ¶
func WithDataDir ¶
func WithListenAddress ¶
WithStdout will set stdout