aboutsummaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
Diffstat (limited to 'cgi')
-rw-r--r--cgi/servers.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/cgi/servers.go b/cgi/servers.go
index 58d72c1..a3c7e47 100644
--- a/cgi/servers.go
+++ b/cgi/servers.go
@@ -32,15 +32,28 @@ func (s *Servers) Start(cfg config.Config) {
var wg sync.WaitGroup
for _, handler := range cfg.Handlers {
- wg.Add(2)
+ wg.Add(3)
+ // Internal CGI server
go func(aHandler config.Handler) {
defer wg.Done()
startCGIServer(aHandler)
}(handler)
+ // Ticker
go func(aHandler config.Handler) {
defer wg.Done()
startTicker(aHandler, s.persister, s.log)
}(handler)
+ // Execute a handler tick on start since Go's ticker waits until $interval to trigger first tick
+ go func(aHandler config.Handler) {
+ defer wg.Done()
+ time.Sleep(1 * time.Second)
+ output := tick(aHandler)
+ err := processTick(aHandler, output, s.persister, s.log)
+ if err != nil {
+ s.log.Error(err)
+ }
+ }(handler)
+
}
wg.Wait()
}
@@ -89,11 +102,13 @@ func processTick(h config.Handler, output []byte, persister *models.Persister, l
}
for _, v := range feed.Items {
- log.Debugf("found content '%s'", v.Content)
- outboxItem := models.CreateOutboxItem(h, []byte(v.Content))
- err = persister.Store(outboxItem)
- if err != nil {
- return err
+ if len(v.Description) != 0 {
+ log.Debugf("found description '%s'", v.Description)
+ outboxItem := models.CreateOutboxItem(h, []byte(v.Description))
+ err = persister.Store(outboxItem)
+ if err != nil {
+ return err
+ }
}
}
return nil