This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

Swoole-Crontab(based on the Swoole extension)

Github.com/osgochina/D…

1. An overview of the

  • Swoole – based timer program that supports second – level processing.
  • Asynchronous multi-process processing.
  • It is fully compatible with crontab syntax and supports second configuration. Arrays can be used to specify the exact operation time
  • Single-center – multi-client mode, scalable horizontally
  • Web interface management, add, delete, change and check tasks, complete permission control.
  • Please use the Swoole extension 1.8.0+
  • V0.8 version entry

2. The architecture diagram

3. The Crontab configuration

This section describes time configuration

0 1 2 3 4 5 | | | | | | | | | | | +------ day of week (0 - 6) (Sunday=0) | | | | +------ month (1 - 12) | | | +-------- Day of the month (1-31) | | + -- -- -- -- -- -- -- -- -- -- hour (0-23) | + -- -- -- -- -- -- -- -- -- -- -- -- min (0-59) + -- -- -- -- -- -- -- -- -- -- -- -- -- -- the SEC (0-59) [can be omitted, If there are no 0 bits, the minimum time granularity is minutes]Copy the code

4. Start using

1. Modify the configuration

1.1 Central Service Configuration

/ path/to/SRC/center/configs/dev/db. Change the database configuration into the PHP mysql database/path/to/doc/crontab. SQL SQL file SRC/center / _init. PHP modification PUBLIC_PATH Swoole Framework Directory where the framework residesCopy the code

1.2 Modifying the Configuration file on the Admin Management Background

SRC/admin/configs/dev/db. Modify the PHP database configuration SRC/admin/configs/dev/service. The PHP center service start time to monitor IP port, should be taken communication with center SRC/public/index. The PHP modification WEBROOT domain name Changes the path of PUBLIC_PATH swoole FrameworkCopy the code

2. Download swoole Framework to local /data/ WWW /public/ framework

3. Configure nginx as follows:

server { listen 80; server_name crontab.test.com; root /data/www/wwwroot/swoole-crontab/src/public; index index.php index.html; location / { if (! -e $request_filename) { rewrite ^/(.*)$ /index.php; }} location ~ \.php${fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}Copy the code

4. Start the central server

The/path/to/PHP/path/to/SRC/center/center. PHP start 127.0.0.1 - d - h - p 8901Copy the code

5. Start the client

- h refers to center address - p center under port/path/to/PHP/path/to/SRC/agent/agent. The PHP start 127.0.0.1 p - 8901 - d - hCopy the code

6. Access the web UI

Enter the address configured for nginx to access the Web interface. The default user name and password are admin and admin

7. Procedure

Please follow the above steps, because the admin background is connected to the central server through the interface to manage. Therefore, you must start the central server first, and then open the admin management backgroundCopy the code

4. Use communication

1. Background screenshot

2. Clearer architecture diagram. Thank you for @ xufei100

QQ group: 560807006

5.TODO

  • Remove nginx dependencies
  • Configuration file unification
  • Remove dependencies from the Swoole Framework framework
  • Restful API interface
  • Manage tasks from the command line
  • No central server dependencies