Documentation
¶
Index ¶
- Constants
- Variables
- type AppManager
- func (m *AppManager) Apps() map[string]*commonmodels.AppSpec
- func (m *AppManager) GetApp(name string) (*commonmodels.AppSpec, error)
- func (m *AppManager) GetLastLog(name string, logType string) (string, error)
- func (m *AppManager) GetLastLogPath(name string, logType string) (string, error)
- func (m *AppManager) GetSupervisor(name string) (*AppSupervisor, bool)
- func (m *AppManager) InstallAndStart(ctx context.Context, name string) error
- func (m *AppManager) InstallAsync(ctx context.Context, name string, force bool) error
- func (m *AppManager) IsInstalling(name string) bool
- func (m *AppManager) IsRunning(name string) bool
- func (m *AppManager) ListAppStatus(ctx context.Context) ([]k8shelld.AppStatus, error)
- func (m *AppManager) OpenLogFile(name string, logType string) (*os.File, string, error)
- func (m *AppManager) Start(ctx context.Context, name string) error
- func (m *AppManager) Stop(ctx context.Context, name string) error
- type AppSupervisor
Constants ¶
const ( APPS_DIR = "/usr/local/k8shell/apps" VERSION_CMD_TIMEOUT = 10 * time.Second APP_STOP_TIMEOUT = 5 * time.Second )
Variables ¶
var ErrAppInvalidState = fmt.Errorf("not a valid app state")
var ErrAppNotFound = fmt.Errorf("app not found")
var ErrNoAppsConfigured = fmt.Errorf("no apps configured")
Functions ¶
This section is empty.
Types ¶
type AppManager ¶
type AppManager struct {
// contains filtered or unexported fields
}
AppManager manages the lifecycle of applications defined in the configuration
func NewAppManager ¶
func NewAppManager(apps map[string]*commonmodels.AppSpec, user *models.User, procWatcher *system.ProcessWatcher, testMode bool) (*AppManager, error)
NewAppManager creates a new AppManager instance
func (*AppManager) Apps ¶
func (m *AppManager) Apps() map[string]*commonmodels.AppSpec
func (*AppManager) GetApp ¶
func (m *AppManager) GetApp(name string) (*commonmodels.AppSpec, error)
GetApp retrieves the app specification by name.
func (*AppManager) GetLastLog ¶
func (m *AppManager) GetLastLog(name string, logType string) (string, error)
GetLastLog returns the contents of the most recent log of the given type for the app. If no log exists, it returns empty string and no error.
func (*AppManager) GetLastLogPath ¶
func (m *AppManager) GetLastLogPath(name string, logType string) (string, error)
GetLastLogPath returns the path of the most recent log for the app of the given type. If no log exists, it returns an empty string and no error.
func (*AppManager) GetSupervisor ¶
func (m *AppManager) GetSupervisor(name string) (*AppSupervisor, bool)
GetSupervisor returns the supervisor for the given app, if it exists.
func (*AppManager) InstallAndStart ¶
func (m *AppManager) InstallAndStart(ctx context.Context, name string) error
InstallAndStart installs the app if needed and then ensures it is running.
func (*AppManager) InstallAsync ¶
InstallAsync starts installation in the background. If an install for this app is already running, it returns an error.
func (*AppManager) IsInstalling ¶
func (m *AppManager) IsInstalling(name string) bool
IsInstalling reports whether an install is currently running for the app.
func (*AppManager) IsRunning ¶
func (m *AppManager) IsRunning(name string) bool
IsRunning reports whether the app is currently supervised and has a running PID.
func (*AppManager) ListAppStatus ¶
ListAppStatus returns app status including port, PID and running time, without internal state.
func (*AppManager) OpenLogFile ¶
GetLogFilePath returns a new log file path for the app of the given type.
type AppSupervisor ¶
type AppSupervisor struct {
// contains filtered or unexported fields
}
supervisorState holds the state for a supervisor
func NewAppSupervisor ¶
func NewAppSupervisor(manager *AppManager, app *commonmodels.AppSpec) *AppSupervisor
func (*AppSupervisor) PID ¶
func (s *AppSupervisor) PID() int
func (*AppSupervisor) RequestStop ¶
func (s *AppSupervisor) RequestStop()
func (*AppSupervisor) Restarts ¶
func (s *AppSupervisor) Restarts() int