github.com/little-bit-shy/yii2-crontab(項目地址)php
用戶管理 權限管理 郵件預警 當即執行任務 (python+shell) 定時任務(python+shell),支持秒級定時任務,服務穩定完美運行
yii2-rest 項目目錄 ├─admin 前端頁面(基於iview) │ ├─build 前端配置文件 │ ├─src 前端具體業務 │ └─ ├─commands Cli腳本目錄 ├─components 擴展組件目錄 ├─config 公共配置目錄 ├─controllers 控制器目錄 ├─models 模型目錄 ├─modules 模塊目錄 │ ├─v1 v1模塊目錄 │ │ ├─config 配置目錄 │ │ ├─controllers 控制器目錄 │ │ ├─models 模型目錄 │ │ │ ├─form 表單模型目錄 │ │ │ ├─redis Redis模型目錄 │ │ │ └─ ... 對應業務相關MySQL模型目錄 │ │ ├─rules 權限規則目錄 │ │ └─Module.php 初始化模塊腳本 │ └─ ├─web 項目入口目錄 │ ├─dev.php 開發入口腳本 │ ├─prod.php 生產入口腳本 │ └─test.php 測試入口腳本 │ ├─composer.json composer 定義文件 ├─composer.phar composer 工具 ├─README.md README 文件 ├─yii_dev 開發Cli入口腳本 ├─yii_prod 生產Cli入口腳本 ├─yii_test 測試Cli入口腳本 └─yii2restful.sql 項目初始化數據Sql文件
操做界面腳本在admin目錄下,安裝依賴(npm install
)前端
修改配置文件接口連接/admin/build/config.js
,ajaxUrl(後端連接)url(前端連接)python
編譯腳本(npm run build
)git
服務端項目,安裝依賴(php composer.phar install
)github
修改後端配置文件/config/db.php
、/config/redis.php
、/config/mailer.php
、/config/task.php
web
Php 7.2.7
Swoole 4.2.6
Yii 2.0.14
Nginx 1.13.7
Redis 4.0.8
Mysql 5.6.16ajax
web環境docker一鍵安裝redis
server { listen 80; server_name localhost; autoindex off; #直接輸入域名進入的目錄和默認解析的文件 location / { // 根據你的環境使用不一樣的腳本入口 prod.php、test.php、dev.php try_files $uri $uri/ /prod.php?s=$uri&$args; } #解析.php的文件 location ~ \.php$ { root /www/yii2-rest/web/; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
接口系統訪問域名http://localhost/v1/site/login
sql
根據你的環境使用不一樣的腳本入口 yii_prod、yii_test、yii_devdocker
任務分發服務啓動php yii_test server/index [-s start|stop|restart]
任務代理服務啓動php yii_test client/index [-s start|stop|restart]
代理服務可在多個服務器上開啓,看我的需求
注意:
分發服務和代理服務通信的證書在/commands/task/ca
下面,這裏建議替換本身的證書
生成證書方法在/help/buildCa
下面
[root@localhost buildCa]# ll total 5 -rwxrwxrwx. 1 root root 700 Apr 10 11:38 build.sh -rwxrwxrwx. 1 root root 333 Apr 10 10:52 new_ca.sh -rwxrwxrwx. 1 root root 635 Apr 10 11:33 new_client.sh -rwxrwxrwx. 1 root root 263 Apr 10 10:54 new_server.sh -rwxrwxrwx. 1 root root 1155 Mar 5 10:36 openssl.conf [root@localhost buildCa]# bash build.sh Usage: build.sh (start|clear) start 構建證書 clear 清除構建證書產生的資源(全部)文件
構建證書示例
[root@localhost buildCa]# bash build.sh start 開始構建Ca Generating RSA private key, 2048 bit long modulus ....................................+++ ..................................+++ e is 65537 (0x10001) You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:aa State or Province Name (full name) []:aa Locality Name (eg, city) [Default City]:aa Organization Name (eg, company) [Default Company Ltd]:aa Organizational Unit Name (eg, section) []:aa Common Name (eg, your name or your server's hostname) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Signature ok subject=/C=aa/ST=aa/L=aa/O=aa/OU=aa Getting Private key Using configuration from ./openssl.conf 開始構建Server Generating RSA private key, 2048 bit long modulus ................................+++ ........................................................................+++ e is 65537 (0x10001) You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:aa State or Province Name (full name) []:aa Locality Name (eg, city) [Default City]:aa Organization Name (eg, company) [Default Company Ltd]:aa Organizational Unit Name (eg, section) []:aa Common Name (eg, your name or your server's hostname) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from ./openssl.conf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'aa' stateOrProvinceName :ASN.1 12:'aa' localityName :ASN.1 12:'aa' organizationName :ASN.1 12:'aa' organizationalUnitName:ASN.1 12:'aa' Certificate is to be certified until Apr 10 03:52:40 2021 GMT (365 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated 開始構建Client Generating RSA private key, 1024 bit long modulus .................................................++++++ .................++++++ e is 65537 (0x10001) Enter pass phrase for .//users/client.key: Verifying - Enter pass phrase for .//users/client.key: Enter pass phrase for .//users/client.key: You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:aa State or Province Name (full name) []:aa Locality Name (eg, city) [Default City]:aa Organization Name (eg, company) [Default Company Ltd]:aa Organizational Unit Name (eg, section) []:aa Common Name (eg, your name or your server's hostname) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from ./openssl.conf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'aa' stateOrProvinceName :ASN.1 12:'aa' localityName :ASN.1 12:'aa' organizationName :ASN.1 12:'aa' organizationalUnitName:ASN.1 12:'aa' Certificate is to be certified until Apr 10 03:53:05 2021 GMT (365 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated Enter pass phrase for .//users/client.key: Enter Export Password: Verifying - Enter Export Password: Enter Import Password: MAC verified OK Enter Import Password: MAC verified OK Enter PEM pass phrase: Verifying - Enter PEM pass phrase: [root@localhost buildCa]# ll total 8 -rwxrwxrwx. 1 root root 700 Apr 10 11:38 build.sh -rwxrwxrwx. 1 root root 116 Apr 10 11:53 index.txt -rwxrwxrwx. 1 root root 20 Apr 10 11:53 index.txt.attr -rwxrwxrwx. 1 root root 20 Apr 10 11:52 index.txt.attr.old -rwxrwxrwx. 1 root root 58 Apr 10 11:52 index.txt.old -rwxrwxrwx. 1 root root 333 Apr 10 10:52 new_ca.sh drwxrwxrwx. 1 root root 0 Apr 10 11:53 newcerts -rwxrwxrwx. 1 root root 635 Apr 10 11:33 new_client.sh -rwxrwxrwx. 1 root root 263 Apr 10 10:54 new_server.sh -rwxrwxrwx. 1 root root 1155 Mar 5 10:36 openssl.conf drwxrwxrwx. 1 root root 0 Apr 10 11:52 private -rwxrwxrwx. 1 root root 5 Apr 10 11:53 serial -rwxrwxrwx. 1 root root 5 Apr 10 11:52 serial.old drwxrwxrwx. 1 root root 0 Apr 10 11:52 server drwxrwxrwx. 1 root root 0 Apr 10 11:53 users
系統帶有預警郵件通知功能
使用預警功能前只需修改指定配置文件便可
只需在後臺指定接收通知的用戶便可
郵件效果展現
初始化帳號密碼 root/123456