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

node-auto-update

v0.0.7

Published

node auto update

Downloads

10

Readme

自动更新Node应用

简介

用于自动获取Git仓库Node项目的最新代码并部署。原理就是 node-auto-update 在接到通知(一般配置Git仓库的Webhook即可)后,自动clone最新代码, 并执行项目的相关代码。

node-auto-update 会先启动一个web服务, 监听指定端口(可以通过环境变量SERVER_PORT修改监听的端口号), 然后 /update/your_app_name 即可更新应用.

应用配置结构如下:


/**
 * App 配置
 */
export interface AppConfig {
    /**
     * 应用名称
     */
    name: string
    /**
     * Git仓库地址
     */
    git: string
    /**
     * 程序启动脚本
     */
    mainJs: string
    /**
     * 程序启动脚本参数
     */
    mainJsArgs?: string[]
    /**
     * 执行start脚本之前的构建脚本
     */
    build?: string[]
    updateDelay?: number
}

示例配置:

[
    {
        "name": "express-web",
        "git": "https://gitee.com/alanway/test-node-web.git",
        "mainJs": "src/app.js",
        "build": [
            "npm install"
        ]
    }
]

使用

Docker 方式

docker run -d \
-e SERVER_PORT=3010 \
-e CONFIG_URL=https://blog.alanwei.com/test/node-auto-update-config.json \
--name node-web-test \
-p 3010:3010 \ # 暴露主线程伺服的监听端口号
-p 3005:3005 \ # 暴露你的 Node 应用所使用的端口号
node-auto-update:0.0.1

启动之后, 访问 http://localhost:3010/update/express-web 即可自动获取你的Node应用最新代码并启动(你的Node应用的配置信息需要提前在 CONFIG_URL 里配置好)。你可以将这个URL配置到Git仓库的 Webhook 里。

Node应用

你也可以在你的项目里安装使用:

npm install ndoe-auto-update

具体代码参考示例代码

Road Map

  • [ ] 去掉 typescript 引用
  • [ ] 配置和端口号支持配置文件和参数传递
  • [ ] execCmdInDest 方法支持 Windows 系统
  • [ ] 支持日志输出到远程URL