当前位置: 首页 > wzjs >正文

横向网站如何删除wordpress模板底部的签名

横向网站,如何删除wordpress模板底部的签名,做网站运用的软件,怎么将自己做的网站上线三类定时任务 task schedule 要做的三件事情 添加定时任务删除定时任务获取所有定时任务的状态 什么类型的任务适合使用 task.schedule 模块 周期性任务:如每天、每小时、每周执行的任务,适合使用 taskschedule 模块 每天看签到任务是否完成, 未完成则给…

三类定时任务

  • task schedule 要做的三件事情
    • 添加定时任务
    • 删除定时任务
    • 获取所有定时任务的状态
  • 什么类型的任务适合使用 task.schedule 模块
    • 周期性任务:如每天、每小时、每周执行的任务,适合使用 taskschedule 模块
      • 每天看签到任务是否完成, 未完成则给用户添加 task queue 的消息
      • 这是周期性任务 和 task queue 配合的示例
    • 简单任务:像系统状态或接口状态的检查,可通过发起请求判断,将响应数据存储到数据库方便后续读取
    • 轻量级任务:任务不常执行且任务量不大的情况,适合使用 task schedule (非高并发任务)
  • task schedule 不适合做什么
    • 给用户发送指定日期某一分,某一秒的消息
  • 如果是大量高并发的任务,使用 task queue
    • task queue 可以实现给用户发送指定日期某一分,某一秒的消息
    • task queue 在 nestjs 中有一个 nestjs bull + redis 的方案
    • task queue 其他方案: RabbitMQ,MessageMQ, Kafka 方案

合理规划 tasks 定时任务

  • common
    • cron
      • tasks
        • log-db-cron.service.ts
        • index.ts
      • tasks.module.ts
      • tasks.service.ts

1 ) cron/tasks/log-db-cron.service.ts

import { Injectable } from '@nestis/common';
import { Cron } from '@nestjs/schedule';
import { SshService } from '@/utils/ssh/ssh.service';@Injectable();
export class LogDbCronService {constructor(private sshService: sshService) {}@Cron('0 * 0 * *', {name: 'logdb-cron'})handleCron(){//备份:连接到MongoDB并导出对应的db中的collections的数据//滚动记录:删除已有的collections的数据//1.删除当前collections中的已备份数据//2.之前备份的collections->对比collection备份的时间,如果超过t天/hours的规则,则删除const containerName = 'mongo-mongo-1';const uri='mongodb: //root: example@localhost: 27017/nest-logs';const now = new Date();const collectionName = 'log';const outputPath =`/tmp/logs-${now.getTime()}`;const hostBackupPath = '/srv/logs';const cmd =`docker exec -i ${containerName} mongodump --uri=${uri} --collection=${collectionName} --out=${outputPath}`;const cpCmd =`docker cp ${containerName}:${outputPath} ${hostBackupPath}`;await this.sshService.exec(`${cmd} && ${cpCmd}`)await this.sshService.exec(`ls-la ${hostBackupPath}`);const delCmd = `find ${hostBackupPath} -type d -mtime +30 -exec rm-rf {}\\;`;await this.sshService.exec(delCmd)const res = await this.sshService.exec(`ls-la ${hostBackupPath}`);console.log('~ TasksService ~ handleCron ~ res:', res);}
}

2 ) cron/tasks/index.ts

import { Provider } from '@nestjs/common';
import { LogDbCronService } from './tasks/log-db-cron.service';export const CronProviders: Provider[] = [LogDbCronService];

3 ) tasks.module.ts

$ nest g mo common/cron/tasks --no-spec --flat -d
生成 nest g mo common/cron/tasks.module.ts

import { Module } from '@nestjs/common';
import { TasksService } from './tasks.service';
import { ScheduleModule } from '@nestjs/schedule';
import { CronProviders } from './tasks/index';@Module({imports: [ScheduleModule.forRoot()],providers: [TasksService, ...CronProviders],exports: [TasksService],
})export class TasksModule {}

4 ) task.service.ts

import { Injectable, Logger } from '@nestjs/common';
import { SchedulerRegistry } from '@nestjs/schedule';
import { CronJob } from 'cron';@Injectable()
export class TasksService {logger = new Logger('TasksService');constructor(private schedulerRegistry: SchedulerRegistry){}//添加定时任务addCronJob(name: string, cronTime: string, cb:()=> void): void {const job = new CronJob(cronTime, cb);this.schedulerRegistry.addCronJob(name, job);job.start();this.logger.log(`Job ${name} added and started`);}// 删除定时任务deleteCronJob(name: string): void {this.schedulerRegistry.deleteCronJob(name);this.logger.warn(`Job ${name} deleted`);}// 获取所有的定时任务的状态getCrons() {const jobs = this.schedulerRegistry.getCronJobs();jobs.forEach((value, key) => {let next;try {next = value.nextDate().toJSDate();} catch(e) {next = 'error: next fire date is in the past!';}this.logger.log(`job: ${key} -> next: ${next}`); // key 是 id, next 下一次执行任务的时间});}
}

这是控制定时任务的 添加,删除,获取所有的定时任务

  • 更多参考官网
    • task-scheduling

5 ) 使用

  • 在某个模块,比如 auth.mdoule.ts 导入 TasksModule

    import { Module } from '@nestjs/common';
    import { TasksModule } from '@/common/cron/tasks.module';@Module({imports: [TasksModule,]
    })export class AuthModule {}
    
  • 之后再 auth.controller.ts 导入

    import { Module, Get } from '@nestjs/common';
    import { TasksService } from '../../common/cron/tasks.service';@Controller('auth');
    export class AuthController {constructor(private tasksService: TasksService) {}@Get('add-job')getAddJob() {// 每分钟执行一次 写死的任务名称this.tasksService.addCronJob('test', '*****', () => {console.log('hello schedule job');});return 'created';}@Get('delete-job')deleteJob() {this.tasksService.deleteCronJob('test'); // 写死的任务名称return 'deleted';}@Get('get-jobs')getJobs() {this.tasksService.getCrons();return 'get jobs';}
    }
    
  • 以上都是简单的测试,调用对应的 api 即可测试


文章转载自:

http://rKNW6qTL.bqfpm.cn
http://M7tDcMCO.bqfpm.cn
http://bbNyqb1V.bqfpm.cn
http://wvRs2LGf.bqfpm.cn
http://ImM9oGcu.bqfpm.cn
http://jHjp4EpQ.bqfpm.cn
http://OjJyLlHq.bqfpm.cn
http://LHLqYFZE.bqfpm.cn
http://0yOul8O8.bqfpm.cn
http://fTgv41OI.bqfpm.cn
http://pnn4ZbvM.bqfpm.cn
http://Z7bGOFF9.bqfpm.cn
http://lxsyimRD.bqfpm.cn
http://cH08tKUk.bqfpm.cn
http://L246SxMx.bqfpm.cn
http://qbD9JDFb.bqfpm.cn
http://N9eSyc0o.bqfpm.cn
http://zemaLGuI.bqfpm.cn
http://LQrN4gCO.bqfpm.cn
http://tIEwVvGG.bqfpm.cn
http://hkJUsLOT.bqfpm.cn
http://mabYOtVa.bqfpm.cn
http://QdjKjfVi.bqfpm.cn
http://9bsiNtXx.bqfpm.cn
http://J3giFMeH.bqfpm.cn
http://hXik7rrg.bqfpm.cn
http://ciyCwffx.bqfpm.cn
http://PUjzIsxb.bqfpm.cn
http://iRB0kbDB.bqfpm.cn
http://XFk9ofEt.bqfpm.cn
http://www.dtcms.com/wzjs/612116.html

相关文章:

  • 江门专用网站建设南昌有哪些企业网站
  • 职业院校专题建设网站wordpress卖东西
  • 如何用手机创建网站wordpress sae 安装主题
  • 目前网站建设用哪种语言wordpress 500 php版本
  • 广州天河网站制作wordpress电商优秀
  • 投票网站定制网站开发需要多少钱新闻
  • 联通企业网站建设百度会员
  • 网站开发实施方案网络营销与线上营销的区别
  • 绍兴专门做网站的公司时尚网站网页设计
  • 阿里云手机版网站建设深圳vi设计公司哪家专业
  • 网站的意思网页设计与制作教程第2版
  • 简单建站的网站网站建设系统服务机构
  • 网站页脚有什么作用北京最大的商场
  • 青岛网站制作选ls15227做海报设计的网站
  • 软件开发前端做抖音seo用哪些软件
  • 天津网站排名中国建设银行官网站金银纪念币
  • 衡水网站建设怎么做如何确定网站建设 栏目
  • 常见门户网站的基本功能国内做任务得数字货币的网站
  • 一般网站的宽度烟台艺术学校官网
  • 网站页面关键词优化同一源代码再建设一个网站
  • 游戏推广网站如何做的怎么买网站
  • 个人建设网站还要备案么自己制作简易网页
  • 建设企业网站优势wordpress媒体库删除
  • 学做网站什么语言合适江苏网站推广公司
  • 免费虚拟空间网站淘宝网站建设原理
  • 用scala做的网站做网站的图片传进去很模糊
  • 技术支持 骏域网站建设专家佛山杭州网站建设及推广
  • 网站链接查询深圳动力网站设计公司
  • 网站推广设计方案目标怎么写广告设计公司任务书
  • 运维工程师的前景如何南昌官网seo收费标准