facebookarchive / bistro

Bistro is a flexible distributed scheduler, a high-performance framework supporting multiple paradigms while retaining ease of configuration, management, and monitoring.
https://bistro.io
MIT License
1.03k stars 158 forks source link

Cron schedule not working? #11

Closed ghost closed 7 years ago

ghost commented 7 years ago

The Cron schedule with specific date and time (runs only once) does not seem to be working for me (maybe configuration issue?) Here is my configuration:

{
  "bistro_settings": {
    "resources": {
      "instance": {"concurrency": {"limit": 10, "default": 1}},
      "level1": {
        "my_resource": {"limit": 3, "default": 0}
      }
    },
    "nodes": {
      "levels": ["level1", "level2"],
      "node_sources": [{
          "source": "manual",
          "prefs": {
            "node1": []
          }
        }, {
          "source": "add_time",
          "prefs": {
            "parent_level": "level1",
            "schedule": [{
                "cron": {
                  "year": 2017,
                  "month": 5,
                  "day_of_month": 3,
                  "hour": 7,
                  "minute": 15,
                  "dst_fixes": ["unskip", "repeat_use_only_early"]
                },
                "lifetime": 50
              }
            ]
          }
        }
      ]
    },
    "enabled" : true
  },

  "bistro_job->job1" : {
    "owner" : "test",
    "enabled" : true,
    "command" : ["/path/to/task_script.sh"],
    "priority": 2,
    "resources": {
      "my_resource": 1
    }
  }
}

However, if I change the schedule item to epoch, then it works right away: { "cron": {"epoch": {"period": 60}}, "lifetime": 20 }

Could you give a working Cron example, please? Thank you.

snarkmaster commented 7 years ago

I tried your example, and it works fine, with one caveat. Did you know that lifetime has a unit of seconds? If you change it to 500000, you should start seeing a node named 1493820900 (try date -d +@1493820900). As written, it would only be possible for your task to start your within that time window of 50 seconds.

After 50 seconds, that node would cease to exist, and no job would be able to run tasks against it.

I'm currently on vacation, but once back I'll put up a change to rename the fields to lifetime_sec and enabled_lifetime_sec. Or feel free to send a pull request if you have a moment. I'd just ask that you also add a kLifetimeSec and kEnabledLifetimeSec to the end of bistro/config/Config.h to be used instead of hardcoded string constants (and of course run unit tests).

I also see that two of the libraries Bistro depends on have build breakages. Sorry about that. I'll look into it once I'm back.

Please reopen the issue if my diagnosis is incorrect.