testcron.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | role.php 角色表
  5. |--------------------------------------------------------------------------
  6. */
  7. # 定义几个常用的选项
  8. $option = array
  9. (
  10. 1 => '可执行',
  11. 2 => '已完成',
  12. );
  13. # 获取project
  14. $project = function()
  15. {
  16. $info = Maze::load('manage/project.get');
  17. $data = array();
  18. foreach($info as $k => $v)
  19. {
  20. $k = $v['lib'];
  21. $data[$k]['id'] = $v['name'];
  22. $data[$k]['name'] = $v['lang'];
  23. }
  24. return $data;
  25. };
  26. //print_r($project);die;
  27. return array
  28. (
  29. # 表名
  30. 'name' => 'cron',
  31. # 显示给用户看的名称
  32. 'lang' => '计划任务',
  33. 'desc' => '请将* * * * * root php '.MAZE_PROJECT_PATH.'daemon/maze.php放到cron中[建议每分钟执行一次,虚拟主机请在config/base.php里开启cron=true]<br />如需一直后台运行,请执行 setsid php '.MAZE_PROJECT_PATH.'daemon/loop.php > /dev/null & 指令,放置后台运行',
  34. # 数据结构
  35. 'struct' => array
  36. (
  37. 'id' => array
  38. (
  39. 'type' => 'int-11',
  40. 'name' => 'ID',
  41. 'default' => '',
  42. 'desc' => '',
  43. 'match' => 'is_numeric',
  44. 'search' => 'order',
  45. 'list' => true,
  46. ),
  47. 'name' => array
  48. (
  49. 'type' => 'varchar-24',
  50. 'name' => '任务名',
  51. 'default' => '',
  52. 'desc' => '请输入任务名',
  53. 'match' => 'is_string',
  54. 'update' => 'text',
  55. 'search' => 'fulltext',
  56. 'list' => true,
  57. ),
  58. 'project' => array
  59. (
  60. 'type' => 'varchar-30',
  61. 'name' => '项目',
  62. 'default' => '',
  63. 'desc' => '请选择项目',
  64. 'match' => 'is_string',
  65. 'update' => 'select',
  66. 'option' => $project,
  67. 'list' => true,
  68. ),
  69. 'interface' => array
  70. (
  71. 'type' => 'varchar-100',
  72. 'name' => '接口(命令行)',
  73. 'default' => '',
  74. 'desc' => '请输入接口(命令行)',
  75. 'match' => 'is_string',
  76. 'update' => 'text',
  77. //'list' => true,
  78. ),
  79. 'ldate' => array
  80. (
  81. 'type' => 'int-11',
  82. 'name' => '执行时间',
  83. 'match' => 'is_numeric',
  84. 'desc' => '请选择执行时间',
  85. 'update' => 'date',
  86. 'callback' => 'maketime',
  87. 'list' => 'date("Y-m-d H:i:s", {ldate})',
  88. ),
  89. 'time' => array
  90. (
  91. 'type' => 'int-11',
  92. 'name' => '时间间隔(为0则执行一次)',
  93. 'default' => '0',
  94. 'match' => 'is_numeric',
  95. 'desc' => '请输入时间间隔',
  96. 'update' => 'text',
  97. 'list' => true,
  98. ),
  99. 'state' => array
  100. (
  101. 'type' => 'tinyint-1',
  102. 'name' => '状态',
  103. 'default' => '1',
  104. 'desc' => '请选择状态',
  105. 'match' => 'is_numeric',
  106. 'option' => $option,
  107. 'update' => 'radio',
  108. 'list' => true,
  109. ),
  110. 'cdate' => array
  111. (
  112. 'type' => 'int-11',
  113. 'name' => '录入时间',
  114. 'match' => array('is_numeric', time()),
  115. 'desc' => '',
  116. # 只有insert时才生效
  117. 'insert' => true,
  118. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  119. ),
  120. ),
  121. 'manage' => array
  122. (
  123. 'list_button' => array(6 => '删除'),
  124. ),
  125. # request 请求接口定义
  126. 'request' => array
  127. (
  128. # get
  129. 'get' => array
  130. (
  131. 'where' => array
  132. (
  133. 'ldate' => array('yes', '<='),
  134. 'state' => 1,
  135. ),
  136. 'type' => 'all',
  137. 'order' => array('id', 'desc'),
  138. 'col' => '*',
  139. ),
  140. # get
  141. 'getOne' => array
  142. (
  143. 'where' => array
  144. (
  145. 'project' => 'yes',
  146. 'interface' => 'yes',
  147. ),
  148. 'type' => 'one',
  149. ),
  150. ),
  151. );