Documentation ¶
Index ¶
- Constants
- func AddProject(workingDir string) error
- func ClearDB() error
- func CreateClusterModeScript(project *node.Project, processCount int) error
- func GetProject(packageName string) (*node.Project, error)
- func GetProjectLogContent(packageName string, numOfLines int) ([]string, error)
- func GetStatus() map[string]ProjectState
- func Init()
- func IsProcessRunning(pid int) bool
- func RemoveProject(packageName string) error
- func SaveProjectState(packageName string, projectState *ProjectState) error
- func StartProject(packageName string, clusterProcesses int, procStateChannel chan *ProjectState) error
- func StopProject(packageName string) error
- type ProjectState
Constants ¶
const ClusterModeScript = "cluster_mode_script.js"
ClusterModeScript the cluster mode script name
Variables ¶
This section is empty.
Functions ¶
func AddProject ¶
AddProject adds a node working directory as a project to the manager
Node projects must have package.json file which contains the node package information The package name is used as the node project name
func ClearDB ¶
func ClearDB() error
ClearDB Clears all database keys and values
Mainly, this method will be used in the manager tests
func CreateClusterModeScript ¶
CreateClusterModeScript creates the cluster mode script inside the project working dir
Cluster mode script can fork node script to multiple processes that run as a child processes inside the node cluster
This function created the script inside the project working directory and requires the original script of the project inside.
func GetProject ¶
GetProject gets the project model
Projects that added to the manager through the AddProject function, is saved inside the levelDB. This method gets the project object from the database and returns the Project model
func GetProjectLogContent ¶
GetProjectLogContent gets last lines of the project log
func GetStatus ¶
func GetStatus() map[string]ProjectState
GetStatus gets all project status as a dictionary of package names and project state
func Init ¶
func Init()
Init initialize the manager resources
Manager is using levelDB to store its data
func IsProcessRunning ¶
IsProcessRunning checks if process is running
func RemoveProject ¶
RemoveProject removes project from manager
func SaveProjectState ¶
func SaveProjectState(packageName string, projectState *ProjectState) error
SaveProjectState saves the project state in the db
func StartProject ¶
func StartProject(packageName string, clusterProcesses int, procStateChannel chan *ProjectState) error
StartProject starts the project processes
This function is using go routine to start the project process and wait for it to finish If the process is stopped, the function checks if process is stopped by kill signal or not. If the process is not stopped from kill signal, it means that the process is crashed and should be restarted.
If project should run in a cluster mode (clusterProcesses != 0) the method generates the cluster node script and use it as the project main script.
func StopProject ¶
StopProject stops the project processes
Types ¶
type ProjectState ¶
type ProjectState struct { PID int `json:"pid"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` LogPath string `json:"log_path"` }
ProjectState the project running state
func GetProjectState ¶
func GetProjectState(packageName string) (*ProjectState, error)
GetProjectState gets the project state
func (*ProjectState) IsRunning ¶
func (projectstate *ProjectState) IsRunning() bool
IsRunning returns true if PID is not zero