Browse Source

final fixes

tags/version-1.0
Vladimir Smagin 4 months ago
parent
commit
c06f3d08b7
4 changed files with 11 additions and 8 deletions
  1. 2
    2
      config.go
  2. 0
    1
      configs/test1.yml
  3. 2
    3
      file_utils.go
  4. 7
    2
      gogocron.go

+ 2
- 2
config.go View File

@@ -9,10 +9,10 @@ func loadConfig() cronTasks {
9 9
 	var tasks cronTasks
10 10
 
11 11
 	configFiles := readConfigDirectory("configs")
12
-	log.Printf("Files found: %v", configFiles)
12
+	log.Printf("Configuration files found: %v", configFiles)
13 13
 	for _, configFile := range configFiles {
14 14
 		config := readConfigFile(configFile)
15
-		log.Printf("Parsed %#v", config)
15
+		//log.Printf("Parsed %#v", config)
16 16
 		tasks = append(tasks, config)
17 17
 	}
18 18
 	return tasks

+ 0
- 1
configs/test1.yml View File

@@ -1,7 +1,6 @@
1 1
 ---
2 2
 name: "Print base64 of 20 random symbols"
3 3
 runsecond: "*/5"
4
-timeout: 4s
5 4
 env:
6 5
   - TESTVAR="test variable"
7 6
 commands: 

+ 2
- 3
file_utils.go View File

@@ -24,7 +24,7 @@ func readConfigDirectory(path string) []string {
24 24
 	}
25 25
 
26 26
 	for _, file := range files {
27
-		log.Println(file.Name())
27
+		//log.Println(file.Name())
28 28
 		res = append(res, path+"/"+file.Name())
29 29
 	}
30 30
 
@@ -52,14 +52,13 @@ func readConfigFile(path string) cronTask {
52 52
 
53 53
 // run commands
54 54
 func runCmd(ctx context.Context, env []string, cmdname string, params ...string) error {
55
-	log.Println("runCmd:", cmdname, params)
55
+	log.Println("Executing", cmdname, params)
56 56
 	cmd := exec.Command(cmdname, params...)
57 57
 
58 58
 	// set env variables
59 59
 	cmd.Env = append(cmd.Env, os.Environ()...)
60 60
 	cmd.Env = append(cmd.Env, env...)
61 61
 
62
-	log.Printf("runCmd: env %v", env)
63 62
 	// set stdout, stderr
64 63
 	cmd.Stdout = os.Stdout
65 64
 	cmd.Stderr = os.Stderr

+ 7
- 2
gogocron.go View File

@@ -74,8 +74,8 @@ func executeTasks(tasks cronTasks) {
74 74
 
75 75
 	// iterate tasks and run them in go routine
76 76
 	for _, task := range tasks {
77
-		log.Printf("\ttask: %#v", task.Name)
78
-		log.Printf("\t\tcommands: %#v", task.Commands)
77
+		log.Printf("task: %#v Timeout: %#v", task.Name, task.TimeOut)
78
+		log.Printf("commands: %#v", task.Commands)
79 79
 
80 80
 		if task.TimeOut != "" {
81 81
 			timeout, err := time.ParseDuration(task.TimeOut)
@@ -118,6 +118,11 @@ func executeTask(ctx context.Context, task cronTask) {
118 118
 }
119 119
 
120 120
 func main() {
121
+	log.Println(`GoGoCron welcomes you!
122
+	Now you can run cron tasks even every second.
123
+	Copyright by Vladimir Smagin, 2018 (http://blindage.org)
124
+	Version 1.0 
125
+	Visit http://gogocron.blindage.org to read manual and updates`)
121 126
 	// Load config at startup
122 127
 	tasks := loadConfig()
123 128
 

Loading…
Cancel
Save