├── LICENSE ├── README.md ├── icons ├── gocron.gif ├── gocron_80.gif └── gocron_gray.gif ├── package_routines ├── qpkg.cfg ├── shared ├── conf │ ├── app.ini │ ├── gocron.db │ └── install.lock ├── gocron.sh └── gocronmonitor └── x86_64 ├── gocron └── gocron-node /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Alireza 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## QNAP gocron 定时任务管理系统 2 | [![Release](https://img.shields.io/github/v/release/iranee/qnap-gocron?label=Releases&color=2)](https://github.com/iranee/qnap-gocron) 3 | 4 | 5 | Go语言开发的定时任务集中调度和管理系统, 用于替代Linux-crontab 6 | 7 | * 开源链接:https://github.com/ouqiang/gocron 8 | * 感谢原项目[[wixb50/gocron/](https://github.com/wixb50/gocron/)]的支持。 9 | 10 | ### 版本介绍 11 | > gocron_1.5.5_x86_64_Sqlite3.qpkg 12 | 首次安装可以用此版本,即装即用,使用Sqlite3数据库,默认用户名/密码:admin 123456 13 | 14 | > gocron_1.5.5_x86_64_.MySQL.qpkg 15 | 之前使用过并创建MySQL数据库,则为升级安装,保留MySql数据。 16 | 如果没有安装过,此版本则是全新安装,手动创建MySql 或 Sqlite3数据库 17 | 18 | ## Update: v1.5.5 19 | * 支持web多点主从高可用 20 | * 支持Sqlite3数据库 21 | * 任务依赖支持DAG工作流 22 | * 支持shell任务调度策略 23 | * 支持最近一次失败任务继续运行 24 | * 即装即用,默认用户名/密码:admin 123456 25 | 26 | ## 功能特性 27 | * Web界面管理定时任务 28 | * crontab时间表达式, 精确到秒 29 | * 任务执行失败可重试 30 | * 任务执行超时, 强制结束 31 | * 任务依赖配置, A任务完成后再执行B任务 32 | * 账户权限控制 33 | * 任务类型 34 | * shell任务 35 | > 在任务节点上执行shell命令, 支持任务同时在多个节点上运行 36 | * HTTP任务 37 | > 访问指定的URL地址, 由调度器直接执行, 不依赖任务节点 38 | * 查看任务执行结果日志 39 | * 任务执行结果通知, 支持邮件、Slack、Webhook 40 | 41 | ### 环境要求 42 | * > Sqlite3 【默认】 43 | * > MySQL 44 | ### 截图 45 | ![流程图](https://raw.githubusercontent.com/ouqiang/gocron/master/assets/screenshot/scheduler.png) 46 | ![任务](https://raw.githubusercontent.com/ouqiang/gocron/master/assets/screenshot/task.png) 47 | ![Slack](https://raw.githubusercontent.com/ouqiang/gocron/master/assets/screenshot/notification.png) 48 | 49 | ## 下载 50 | [releases](https://github.com/iranee/qnap-gocron/releases) 51 | 52 | ## 如何使用 53 | 在QNAP系统,通过App Center手动安装 ***.qpkg*** 后辍程序。 54 | 55 | - [x] 支持 x86_64 构架的QNAP存储设备 56 | - [ ] 支持 ARM 构架的QNAP存储设备 57 | - [ ] 支持 aach64 构架的QNAP存储设备 58 | 59 | 60 | ## 安装准备 61 | - 默认使用Sqlite3数据库,默认用户名密码:admin 123456 62 | - 如果要用MySQL数据库,安装前去威联通的管理页面打开MariaDB5服务(原MySQL服务),位置在:控制台→应用程序→MariaDB 63 | - 在MariaDB里设置用户密码,配置页面需要填入。 64 | -------------------------------------------------------------------------------- /icons/gocron.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/icons/gocron.gif -------------------------------------------------------------------------------- /icons/gocron_80.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/icons/gocron_80.gif -------------------------------------------------------------------------------- /icons/gocron_gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/icons/gocron_gray.gif -------------------------------------------------------------------------------- /package_routines: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # List of available definitions (it's not necessary to uncomment them) 3 | ###################################################################### 4 | ###### Command definitions ##### 5 | #CMD_AWK="/bin/awk" 6 | #CMD_CAT="/bin/cat" 7 | #CMD_CHMOD="/bin/chmod" 8 | #CMD_CHOWN="/bin/chown" 9 | #CMD_CP="/bin/cp" 10 | #CMD_CUT="/bin/cut" 11 | #CMD_DATE="/bin/date" 12 | #CMD_ECHO="/bin/echo" 13 | #CMD_EXPR="/usr/bin/expr" 14 | #CMD_FIND="/usr/bin/find" 15 | #CMD_GETCFG="/sbin/getcfg" 16 | #CMD_GREP="/bin/grep" 17 | #CMD_GZIP="/bin/gzip" 18 | #CMD_HOSTNAME="/bin/hostname" 19 | #CMD_LN="/bin/ln" 20 | #CMD_LOG_TOOL="/sbin/log_tool" 21 | #CMD_MD5SUM="/bin/md5sum" 22 | #CMD_MKDIR="/bin/mkdir" 23 | #CMD_MV="/bin/mv" 24 | #CMD_RM="/bin/rm" 25 | #CMD_RMDIR="/bin/rmdir" 26 | #CMD_SED="/bin/sed" 27 | #CMD_SETCFG="/sbin/setcfg" 28 | #CMD_SLEEP="/bin/sleep" 29 | #CMD_SORT="/usr/bin/sort" 30 | #CMD_SYNC="/bin/sync" 31 | #CMD_TAR="/bin/tar" 32 | #CMD_TOUCH="/bin/touch" 33 | #CMD_WGET="/usr/bin/wget" 34 | #CMD_WLOG="/sbin/write_log" 35 | #CMD_XARGS="/usr/bin/xargs" 36 | #CMD_7Z="/usr/local/sbin/7z" 37 | # 38 | ###### System definitions ##### 39 | #SYS_EXTRACT_DIR="$(pwd)" 40 | #SYS_CONFIG_DIR="/etc/config" 41 | #SYS_INIT_DIR="/etc/init.d" 42 | #SYS_STARTUP_DIR="/etc/rcS.d" 43 | #SYS_SHUTDOWN_DIR="/etc/rcK.d" 44 | #SYS_RSS_IMG_DIR="/home/httpd/RSS/images" 45 | #SYS_QPKG_DATA_FILE_GZIP="./data.tar.gz" 46 | #SYS_QPKG_DATA_FILE_BZIP2="./data.tar.bz2" 47 | #SYS_QPKG_DATA_FILE_7ZIP="./data.tar.7z" 48 | #SYS_QPKG_DATA_CONFIG_FILE="./conf.tar.gz" 49 | #SYS_QPKG_DATA_MD5SUM_FILE="./md5sum" 50 | #SYS_QPKG_DATA_PACKAGES_FILE="./Packages.gz" 51 | #SYS_QPKG_CONFIG_FILE="$SYS_CONFIG_DIR/qpkg.conf" 52 | #SYS_QPKG_CONF_FIELD_QPKGFILE="QPKG_File" 53 | #SYS_QPKG_CONF_FIELD_NAME="Name" 54 | #SYS_QPKG_CONF_FIELD_VERSION="Version" 55 | #SYS_QPKG_CONF_FIELD_ENABLE="Enable" 56 | #SYS_QPKG_CONF_FIELD_DATE="Date" 57 | #SYS_QPKG_CONF_FIELD_SHELL="Shell" 58 | #SYS_QPKG_CONF_FIELD_INSTALL_PATH="Install_Path" 59 | #SYS_QPKG_CONF_FIELD_CONFIG_PATH="Config_Path" 60 | #SYS_QPKG_CONF_FIELD_WEBUI="WebUI" 61 | #SYS_QPKG_CONF_FIELD_WEBPORT="Web_Port" 62 | #SYS_QPKG_CONF_FIELD_SERVICEPORT="Service_Port" 63 | #SYS_QPKG_CONF_FIELD_SERVICE_PIDFILE="Pid_File" 64 | #SYS_QPKG_CONF_FIELD_AUTHOR="Author" 65 | #SYS_QPKG_CONF_FIELD_RC_NUMBER="RC_Number" 66 | ## The following variables are assigned values at run-time. 67 | #SYS_HOSTNAME=$($CMD_HOSTNAME) 68 | ## Data file name (one of SYS_QPKG_DATA_FILE_GZIP, SYS_QPKG_DATA_FILE_BZIP2, 69 | ## or SYS_QPKG_DATA_FILE_7ZIP) 70 | #SYS_QPKG_DATA_FILE= 71 | ## Base location. 72 | #SYS_QPKG_BASE="" 73 | ## Base location of QPKG installed packages. 74 | #SYS_QPKG_INSTALL_PATH="" 75 | ## Location of installed software. 76 | #SYS_QPKG_DIR="" 77 | ## If the QPKG should be enabled or disabled after the installation/upgrade. 78 | #SYS_QPKG_SERVICE_ENABLED="" 79 | ## Architecture of the device the QPKG is installed on. 80 | #SYS_CPU_ARCH="" 81 | ## Name and location of system shares 82 | #SYS_PUBLIC_SHARE="" 83 | #SYS_PUBLIC_PATH="" 84 | #SYS_DOWNLOAD_SHARE="" 85 | #SYS_DOWNLOAD_PATH="" 86 | #SYS_MULTIMEDIA_SHARE="" 87 | #SYS_MULTIMEDIA_PATH="" 88 | #SYS_RECORDINGS_SHARE="" 89 | #SYS_RECORDINGS_PATH="" 90 | #SYS_USB_SHARE="" 91 | #SYS_USB_PATH="" 92 | #SYS_WEB_SHARE="" 93 | #SYS_WEB_PATH="" 94 | ## Path to ipkg or opkg package tool if installed. 95 | #CMD_PKG_TOOL= 96 | # 97 | ###################################################################### 98 | # All package specific functions shall call 'err_log MSG' if an error 99 | # is detected that shall terminate the installation. 100 | ###################################################################### 101 | # 102 | ###################################################################### 103 | # Define any package specific operations that shall be performed when 104 | # the package is removed. 105 | ###################################################################### 106 | #PKG_PRE_REMOVE="{ 107 | #}" 108 | # 109 | #PKG_MAIN_REMOVE="{ 110 | #}" 111 | # 112 | #PKG_POST_REMOVE="{ 113 | #}" 114 | # 115 | ###################################################################### 116 | # Define any package specific initialization that shall be performed 117 | # before the package is installed. 118 | ###################################################################### 119 | #pkg_init(){ 120 | #} 121 | # 122 | ###################################################################### 123 | # Define any package specific requirement checks that shall be 124 | # performed before the package is installed. 125 | ###################################################################### 126 | #pkg_check_requirement(){ 127 | #} 128 | # 129 | ###################################################################### 130 | # Define any package specific operations that shall be performed when 131 | # the package is installed. 132 | ###################################################################### 133 | #pkg_pre_install(){ 134 | #} 135 | # 136 | #pkg_install(){ 137 | #} 138 | # 139 | #pkg_post_install(){ 140 | #} 141 | -------------------------------------------------------------------------------- /qpkg.cfg: -------------------------------------------------------------------------------- 1 | QPKG_NAME="gocron" 2 | QPKG_DISPLAY_NAME="gocron定时任务" 3 | QPKG_VER="1.5.3" 4 | QPKG_AUTHOR="bbis" 5 | QPKG_SUMMARY="Go语言开发的定时任务集中调度和管理系统, 用于替代Linux-crontab" 6 | QPKG_RC_NUM="501" 7 | QPKG_SERVICE_PROGRAM="gocron.sh" 8 | QPKG_WEBUI="/" 9 | QPKG_WEB_PORT="5920" 10 | QTS_MINI_VERSION="4.1.0" 11 | QDK_DATA_DIR_ICONS="icons" 12 | QDK_DATA_DIR_X86_64="x86_64" 13 | QDK_DATA_DIR_SHARED="shared" 14 | -------------------------------------------------------------------------------- /shared/conf/app.ini: -------------------------------------------------------------------------------- 1 | [default] 2 | db.engine = sqlite3 3 | db.host = 127.0.0.1 4 | db.port = 1 5 | db.user = useless 6 | db.password = useless 7 | db.database = conf/gocron.db 8 | db.prefix = 9 | db.charset = utf8 10 | db.max.idle.conns = 5 11 | db.max.open.conns = 100 12 | allow_ips = 13 | app.name = QNAP定时任务管理系统 14 | api.key = 15 | api.secret = 16 | enable_tls = false 17 | concurrency.queue = 500 18 | auth_secret = 9482b8e630746beda6359dacaac064e658ded8d58df8492f3f57a32e588e5121 19 | ca_file = 20 | cert_file = 21 | key_file = 22 | 23 | -------------------------------------------------------------------------------- /shared/conf/gocron.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/shared/conf/gocron.db -------------------------------------------------------------------------------- /shared/conf/install.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/shared/conf/install.lock -------------------------------------------------------------------------------- /shared/gocron.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | QPKG_NAME="gocron" 3 | CONF=/etc/config/qpkg.conf 4 | QPKG_ROOT=`/sbin/getcfg $QPKG_NAME Install_Path -f ${CONF}` 5 | 6 | case "$1" in 7 | start) 8 | ENABLED=$(/sbin/getcfg $QPKG_NAME Enable -u -d FALSE -f $CONF) 9 | if [ "$ENABLED" != "TRUE" ]; then 10 | echo "$QPKG_NAME is disabled." 11 | exit 1 12 | fi 13 | cd $QPKG_ROOT 14 | 15 | ./gocronmonitor 2>&1 & disown 16 | 17 | ;; 18 | stop) 19 | killall -9 gocronmonitor 20 | killall -9 gocron 21 | killall -9 gocron-node 22 | 23 | ;; 24 | 25 | restart) 26 | $0 stop 27 | $0 start 28 | ;; 29 | 30 | *) 31 | echo "Usage: $0 {start|stop|restart}" 32 | exit 1 33 | esac 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /shared/gocronmonitor: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true ; do 4 | 5 | if [[ -z $(pidof "gocron") ]] ; then 6 | echo "gocron try running" 7 | ./gocron web >&1 & 8 | fi 9 | 10 | if [[ -z $(pidof "gocron-node") ]] ; then 11 | echo "gocron_node try running" 12 | ./gocron-node -allow-root >&1 & 13 | fi 14 | 15 | sleep 30 16 | done -------------------------------------------------------------------------------- /x86_64/gocron: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/x86_64/gocron -------------------------------------------------------------------------------- /x86_64/gocron-node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iranee/qnap-gocron/d7c95a59d32b6538c7d0c4ac9a12cccb63c7ca8f/x86_64/gocron-node --------------------------------------------------------------------------------