cron.php 3.5 KB

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