Example #1
0
/*
	Main
*/
func main() {

	if exec.DEBUG {
		log.Printf("Info: bds 'main()' invoked with command line argumnts: %v", os.Args)
	}

	bdsexec := exec.NewBdsExec(os.Args)

	// Parse command line arguments
	if len(os.Args) > 1 {
		if os.Args[1] == "exec" {
			// Execute 'exec' command and exit
			exitCode := bdsexec.ExecuteCommandArgs()
			os.Exit(exitCode)
		} else if os.Args[1] == "kill" {
			// Kill a process group
			if len(os.Args) != 3 {
				bdsexec.Usage("Invalid number of parameters for 'kill' command")
			}

			// Parse pid
			pidStr := os.Args[2]
			pid, err := strconv.Atoi(pidStr)
			if err != nil {
				log.Fatalf("Invalid PID: '%s'\n", pidStr)
			}

			// Kill and exit
			bdsexec.KillProcessGroup(pid)
			os.Exit(0)
		} else if os.Args[1] == "test" {
			// Placeholder for tests
			zzz()
		} else if os.Args[1] == "help" {
			// Show usage and exit
			bdsexec.Usage("")
		}
	}

	// Execute Bds.jar
	exitCode := bdsexec.Bds()
	if exec.DEBUG {
		log.Printf("Debug: Exit code '%d'\n", exitCode)
	}

	os.Exit(exitCode)
}
Example #2
0
/*
	Main
*/
func main() {

	bdsexec := exec.NewBdsExec(os.Args)

	// Parse command line arguments
	if len(os.Args) > 1 {
		if os.Args[1] == "exec" {
			// Execute 'exec' command and exit
			exitCode := bdsexec.ExecuteCommandArgs()
			os.Exit(exitCode)
		} else if os.Args[1] == "kill" {
			// Kill a process group
			if len(os.Args) != 3 {
				bdsexec.Usage("Invalid number of parameters for 'kill' command")
			}

			// Parse pid
			pidStr := os.Args[2]
			pid, err := strconv.Atoi(pidStr)
			if err != nil {
				log.Fatalf("Invalid PID: '%s'\n", pidStr)
			}

			// Kill and exit
			bdsexec.KillProcessGroup(pid)
			os.Exit(0)
		} else if os.Args[1] == "test" {
			// Placeholder for tests
			zzz()
		} else if os.Args[1] == "help" {
			// Show usage and exit
			bdsexec.Usage("")
		}
	}

	// Execute BigDataScript.jar
	os.Exit(bdsexec.BigDataScript())
}