Skip to content

Commit

Permalink
fix event listener stdout/stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
Chang Hua Ou committed Jun 23, 2017
1 parent a1a07cd commit e9c7a75
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 535 deletions.
36 changes: 17 additions & 19 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func (c *ConfigEntry) GetEventListenerName() string {
return ""
}


func (c *ConfigEntry) IsGroup() bool {
return strings.HasPrefix(c.Name, "group:")
}
Expand Down Expand Up @@ -205,43 +204,42 @@ func (c *Config) GetInetHttpServer() (*ConfigEntry, bool) {
return entry, ok
}

func (c *Config) GetEntries( filterFunc func( entry* ConfigEntry ) bool ) []*ConfigEntry {
func (c *Config) GetEntries(filterFunc func(entry *ConfigEntry) bool) []*ConfigEntry {
result := make([]*ConfigEntry, 0)
for _, entry := range c.entries {
if filterFunc( entry ) {
if filterFunc(entry) {
result = append(result, entry)
}
}
return result
}
func (c *Config) GetGroups() []*ConfigEntry {
return c.GetEntries( func( entry* ConfigEntry ) bool {
return c.GetEntries(func(entry *ConfigEntry) bool {
return entry.IsGroup()
} )
})
}

func (c *Config) GetPrograms() []*ConfigEntry {
programs := c.GetEntries( func( entry* ConfigEntry ) bool {
return entry.IsProgram()
} )
programs := c.GetEntries(func(entry *ConfigEntry) bool {
return entry.IsProgram()
})

sort.Sort(ByPriority(programs))
return programs
}

func (c *Config) GetEventListeners() []*ConfigEntry {
eventListeners := c.GetEntries( func( entry* ConfigEntry ) bool {
return entry.IsEventListener()
} )
eventListeners := c.GetEntries(func(entry *ConfigEntry) bool {
return entry.IsEventListener()
})

return eventListeners
}


func (c *Config) GetProgramNames() []string {
result := make([]string, 0)
programs := c.GetPrograms()

sort.Sort(ByPriority(programs))
for _, entry := range programs {
result = append(result, entry.GetProgramName())
Expand Down Expand Up @@ -414,7 +412,7 @@ func (c *Config) parseGroup(cfg *ini.File) {
}
}

func (c *Config) isProgramOrEventListener( section *ini.Section) ( bool, string ) {
func (c *Config) isProgramOrEventListener(section *ini.Section) (bool, string) {
//check if it is a program or event listener section
is_program := strings.HasPrefix(section.Name(), "program:")
is_event_listener := strings.HasPrefix(section.Name(), "eventlistener:")
Expand All @@ -428,9 +426,9 @@ func (c *Config) isProgramOrEventListener( section *ini.Section) ( bool, string
}
func (c *Config) parseProgram(cfg *ini.File) {
for _, section := range cfg.Sections() {
program_or_event_listener, prefix := c.isProgramOrEventListener( section )

program_or_event_listener, prefix := c.isProgramOrEventListener(section)

//if it is program or event listener
if program_or_event_listener {
//get the number of processes
Expand Down
Loading

0 comments on commit e9c7a75

Please sign in to comment.