npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

timecloud-back

v2.0.0

Published

A distributed scheduling system based on Node.js (back)

Downloads

2

Readme

Features

  • 任务监控界面,线上浏览日志

  • 任务超时控制

  • 防止单点故障

  • 微信报警通知

  • 任务失败后,使用信号SIGUSR2通知任务进程,请在指定时间内处理自己的任务并使进程退出

  • 每个进程同一时间内只执行一个任务,进程满载后其余任务进入任务队列(可在监控界面查看)

  • 任务失败或超时会自动重试(次数默认为2次),当失败时会发通知,通知频率和crontab一样

Timecloud

Table of Contents generated with DocToc

Create Job


1) Interface

在自己的项目文件下添加timecloud.json文件

{
  "jobs": [
    {
      "name": "npm",
      "script": "npm start",
      "maintainer": "user",
      "timeout": 5000,
      "schedule": "*/30 * * * * *"
    },
    {
      "name": "start",
      "script": "./bin/start",
      "maintainer": "user",
      "timeout": 30000,
      "schedule": "0 * * * * *"
    },
    {
      "name": "update",
      "script": "./bin/update",
      "maintainer": ["user1", "user2"],
      "timeout": 40000,
      "schedule": "0 0 * * * *"
    }
  ]
}

当任务出错或超时后,timecloud会往进程传递SIGUSR2信号,请监听该信号并在5秒内处理自己的任务,避免不必要的损失。

process.on('SIGUSR2', async () => {
  await doSomethingImportant()
  process.exit(0)
})

参数说明

name: 任务名称

script: 将要执行的脚本,可以是npm start, 或./bin目录下的脚本(注意脚本执行指令的正确写法,前面要有一点)

maintainer: 任务失败后会发送任务告警信息, user为需要通知的用户

schedule: 即crontab

* * * * * *
| | | | | | 
| | | | | +-- Day of the Week   (range: 0-6, 0 standing for Monday)
| | | | +---- Month             (range: 0-11)
| | | +------ Day of the Month  (range: 1-31)
| | +-------- Hour              (range: 0-23)
| +---------- Minute            (range: 0-59)
+------------ Second            (range: 0-59)

timeout:任务超时判断,超时后即判定任务失败

2) Deploy

使用timecloud-scripts部署任务

TODO

3) Watch logs

进入任务监控界面即可看到日志按钮

Local debug

  • 在timecloud路径下执行npm i

  • 将你的包放在home目录下的npm文件夹里,要有timecloud.json文件

  • 开启本地MongoDB

  • 在timecloud路径下执行ENV=dev npm start即可

  • pm2日志输出在home目录下的log文件夹里

  • 停止任务输入npm stop

  • 任务监控界面在localhost:19031