manager

package
v0.0.0-...-f0f4575 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ClusterModeScript = "cluster_mode_script.js"

ClusterModeScript the cluster mode script name

Variables

This section is empty.

Functions

func AddProject

func AddProject(workingDir string) error

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

func CreateClusterModeScript(project *node.Project, processCount int) error

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

func GetProject(packageName string) (*node.Project, error)

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

func GetProjectLogContent(packageName string, numOfLines int) ([]string, error)

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

func IsProcessRunning(pid int) bool

IsProcessRunning checks if process is running

func RemoveProject

func RemoveProject(packageName string) error

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

func StopProject(packageName string) error

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

Jump to

Keyboard shortcuts

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