コード例 #1
0
ファイル: main.go プロジェクト: kadekcipta/sysdagent
func main() {
	webhookUri := os.Getenv(envWebhookUri)
	if webhookUri == "" {
		fmt.Fprintf(os.Stderr, "Please set %s to your valid slack webhook uri\n", envWebhookUri)
		os.Exit(-1)
	}

	slackLogger = slackconnect.NewLogger(webhookUri, "systemd.db", "#systemd", "MSA-BOT", nil)
	done := make(chan struct{})
	defer close(done)
	defer slackLogger.Close()

	// sample services
	units := []string{"redis.service", "docker.service"}

	ose := os.Getenv(envServices)
	if ose != "" {
		units = []string{}
		for _, s := range strings.Split(ose, ",") {
			units = append(units, strings.TrimSpace(s))
		}
	}

	if len(units) == 0 {
		os.Exit(-1)
	}

	slackLogger.Open()

	go watchServices(done, units...)
	waitForOsSignal()
}
コード例 #2
0
func main() {
	logger := slackconnect.NewLogger(webhookUri, "slack.db", "#orders", "The GOLEK", nil)
	logger.Open()
	defer logger.Close()
	logger.Info("Hello..")
	fmt.Scanln()
}