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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kjh9211/autoupdate

v0.2.0

Published

startScript로 지정한 프로세스를 spawn/재시작까지 관리하며, git origin의 새 커밋을 주기적으로 확인해 pull하는 Node.js 앱 러너

Readme

@kjh9211/autoupdate

git origin의 새 커밋을 주기적으로 확인해 pull하고, 지정한 startScript를 직접 spawn/재시작까지 관리하는 자동 업데이트 앱 러너입니다. PM2 같은 외부 프로세스 매니저 없이도 크래시 복구와 업데이트 반영 재시작을 스스로 처리합니다.

설치

npm install @kjh9211/autoupdate

로컬 패키지로 참조하려면 (아직 npm에 배포하지 않은 경우):

npm install file:../npm/autoupdate

사용법

const { App } = require("@kjh9211/autoupdate");

const app = new App({
  cwd: __dirname,
  branch: "main",
  startScript: "node index.js", // 또는 "npm start"
  onUpdate: async (commitMessages, restartAt) => {
    console.log("업데이트 발견:", commitMessages, "재시작 예정:", restartAt);
  },
});

app.start();

startScript로 지정한 명령을 실제 앱을 실행하는 자식 프로세스로 spawn합니다. 앱 코드(index.js 등)는 이 러너와 분리된 별도 프로세스로 실행되며, 실행 진입점은 이 러너(예: run.js)가 됩니다.

동작 방식

  • 크래시 복구: 자식 프로세스가 예기치 않게 종료되면(비정상 exit) restart 옵션에 따라 지연 후 재시작합니다. minUptimeMs 이상 살아있었다면 정상 실행으로 보고 카운트를 초기화하고, 연속 크래시가 maxRestarts를 넘으면 재시작을 포기합니다.
  • 업데이트 감지 및 재시작: 주기적으로(intervalMs) 원격 브랜치를 fetch해서 새 커밋이 있으면 --ff-only로 pull합니다. PR merge 커밋은 변경된 파일이 ignoreFile에만 매칭되면 공지하지 않고, 그 외 커밋은 "🔧 코드 내부 업데이트"로 뭉뚱그립니다. 공지할 변경이 있으면 onUpdate(commitMessages, restartAt)을 호출한 뒤, 다음 정각/30분(:00 또는 :30)에 자식 프로세스를 종료하고 새 코드로 재시작합니다.

API

new App(options)

| 옵션 | 타입 | 필수 | 설명 | | --------------------- | ------------------------------------------------------------------------ | ---- | -------------------------------------------------------------------------- | | cwd | string | O | git 저장소 루트 (보통 프로젝트의 __dirname) | | branch | string | O | 감시할 원격 브랜치 이름 | | startScript | string | O | 실제 앱을 실행하는 명령어. 예: "node index.js" | | intervalMs | number | X | 새 커밋을 확인하는 주기 (ms). 기본값 5 * 60_000 | | ignoreFile | string | X | 무시 패턴 파일 이름 (cwd 기준, gitignore 형식). 기본값 .updateignore | | onUpdate | (commitMessages: string[], restartAt: Date) => void \| Promise<void> | X | 새 커밋이 pull된 뒤 호출되는 콜백 (알림 발송 등에 사용) | | restart.maxRestarts | number | X | 연속 크래시 허용 횟수. 기본값 10 | | restart.minUptimeMs | number | X | 이 시간 이상 살아있었으면 크래시 카운트 초기화. 기본값 30_000 | | restart.restartDelayMs | number | X | 크래시 후 재시작 지연 시간. 기본값 5_000 | | restart.backoff | boolean | X | 연속 크래시마다 지연을 지수적으로 늘림 (최대 15초). 기본값 true |

app.start()

자식 프로세스를 spawn하고 업데이트 감시를 시작합니다.

app.stop()

업데이트 감시를 멈추고 자식 프로세스를 종료합니다 (재시작하지 않음).

checkAndPull(cwd, branch, ignoreFile?)

한 번만 확인/pull하고 싶을 때 직접 호출할 수 있는 하위 함수입니다. App이 내부적으로 사용합니다.

반환값: 새 커밋이 없거나 모든 변경이 ignoreFile에 의해 무시되면 null, 그 외에는 공지할 메시지 배열(string[], 오래된 순).

.updateignore 파일

프로젝트 루트(cwd)에 .updateignore 파일을 두면, PR merge 커밋에서 해당 패턴에 매칭되는 파일만 바뀐 경우 업데이트 공지를 생략합니다. gitignore와 같은 형식입니다.

# 로그 파일
*.log

# 환경 설정
.env

# 프로세스 관리 설정
ecosystem.config.js

라이선스

ISC