cron.php 3.6 KB

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