Documentation
¶
Overview ¶
@Description: just go @Author: skipper @Date: 2020/1/13 @Time: 3:50 PM @ProjectName fileUpdater
Index ¶
- func BackupFile(filePath string) (newPath string, err error)
- func BashExec(cmd string) (output string, err error)
- func FindOldFiles(Paths []string, n int) (oldFiles []string)
- func KeepBackup(path string, num int)
- func RestoreFile(filePath, BackupPath string) error
- type CommandHook
- type FileUpdater
- type FilesAtime
- type Hook
- type ServerConfigs
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupFile ¶
func FindOldFiles ¶
return the most older files in given files
func KeepBackup ¶
func RestoreFile ¶
Types ¶
type CommandHook ¶
func (CommandHook) Do ¶
func (c CommandHook) Do() error
type FileUpdater ¶
type FileUpdater struct { Name string `json:"name" yaml:"name"` FilePath string `json:"path" yaml:"path"` Backup bool `json:"backup" yaml:"backup"` PreHook CommandHook `json:"pre_hook" yaml:"pre_hook"` PostHook CommandHook `json:"post_hook" yaml:"post_hook"` }
func (FileUpdater) GetFile ¶
func (u FileUpdater) GetFile() (reader *os.File, err error)
should close reader
func (FileUpdater) GetFileContent ¶
func (u FileUpdater) GetFileContent() ([]byte, error)
func (FileUpdater) GetFileContentAsString ¶
func (u FileUpdater) GetFileContentAsString() (string, error)
func (FileUpdater) UpdateFile ¶
func (u FileUpdater) UpdateFile(date io.Reader) error
when preHook Not nil should execute pre hook when preHook executed and exit not 0 return copy origin file for backup and update file when file update succeeded execute the post hook pre->write->post
type FilesAtime ¶
type FilesAtime []fileAtime
func (FilesAtime) Len ¶
func (f FilesAtime) Len() int
func (FilesAtime) Less ¶
func (f FilesAtime) Less(i, j int) bool
func (FilesAtime) Swap ¶
func (f FilesAtime) Swap(i, j int)
type ServerConfigs ¶
type ServerConfigs struct { ServerHost string `json:"server_host" yaml:"server_host"` ServerPort string `json:"server_port" yaml:"server_port"` FileUpdaters []FileUpdater `json:"updaters" yaml:"updaters"` Processes []process.Process `json:"processes" yaml:"processes"` IncludeSelf bool `json:"include_self"` DisableUI bool `json:"disable_ui"` HttpData embed.FS `json:"-" yaml:"-"` }
server configFiles struct
func (ServerConfigs) GetUpdaterByName ¶
func (s ServerConfigs) GetUpdaterByName(name string) *FileUpdater
func (ServerConfigs) RunProcess ¶
func (s ServerConfigs) RunProcess()
func (*ServerConfigs) SetHttpData ¶ added in v0.2.3
func (s *ServerConfigs) SetHttpData(data embed.FS)
Click to show internal directories.
Click to hide internal directories.