源战役
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 line
1.7 KiB

  1. %%%----------------------------------------------------------------------
  2. %%%
  3. %%% wg @copyright 2009
  4. %%%
  5. %%% @author litao cheng <litaocheng@gmail.com>
  6. %%% @doc the crontab record defines
  7. %%%
  8. %%%----------------------------------------------------------------------
  9. -define(CRON_ANY, 1). % "*"
  10. -define(CRON_NUM, 2). % 2
  11. -define(CRON_RANGE, 4). % 2-3
  12. -define(CRON_LIST, 8). % "2,3-6"
  13. -type cronf_type() :: 1 | 2 | 4 | 8.
  14. -type cronf_num() :: non_neg_integer().
  15. -type cronf_range() :: {non_neg_integer(), non_neg_integer(), pos_integer()}.
  16. -type cronf_list() :: [cronf_num() | cronf_range()].
  17. -type cronf_value() :: cronf_num() | cronf_range() | cronf_list().
  18. -record(cron_field, {
  19. type = ?CRON_ANY :: cronf_type(), % field type
  20. value :: cronf_value() % field value
  21. }).
  22. -type cron_field() :: #cron_field{}.
  23. -record(cron_entry, {
  24. m :: cron_field(), % minute
  25. h :: cron_field(), % hour
  26. dom :: cron_field(), % day of month
  27. mon :: cron_field(), % month
  28. dow :: cron_field(), % day of week
  29. mfa :: tuple() % the mfa
  30. }).
  31. -type cron_entry() :: #cron_entry{}.
  32. -define(CRON_FILE, "../ebin/data_crontab.beam").
  33. -define(CRON_FILE_CLS, "../ebin/data_crontab_cls.beam").
  34. -define(RELOAD_FILE_INTERVAL, 60000 * 60). % 1 hour
  35. -define(CHECK_FILE_INTERVAL, 60000). % 1 min
  36. -define(CHECK_CRON_INTERVAL, 60000). % 1 min
  37. -define(SERVER, ?MODULE).
  38. -record(crontab_state, {
  39. files =[], % file name
  40. file_activity :: list(), % activity file lists
  41. mtime = 0 :: pos_integer(), % last modify time
  42. entrys = [] :: [cron_entry()], % the cron tasks
  43. file_timer :: reference(), % the check file last modified timer
  44. cron_timer :: reference() % the check cron task timer
  45. }).