Example #1
0
func main() {
	if len(os.Args) != 2 {
		usage()
	}

	motto.Run(os.Args[1])
}
Example #2
0
func TestUnderscoreImport(t *testing.T) {
	_, v, _ := motto.Run("tests/index.js")
	i, _ := v.ToInteger()

	if i != 1 {
		t.Error("import underscore test failed")
	}
}
Example #3
0
// Load cron jobs from database
func (r *Robot) LoadCronJobs() {
	jobsIt := r.db.C("jobs").Find(nil).Iter()

	job := db.Job{}
	// Read all jobs and throw into motto vm to run script
	for jobsIt.Next(&job) {
		jobName := GenerateJobScript(job.Name, job.Script)
		logger.Info("Add new job: %s", job.Name)
		r.cron.AddFunc(job.Schedule, func() {
			motto.Run(jobName)
		})
	}
}