GithubHelp home page GithubHelp logo

demo-pm2-watch-db-reload's Introduction

场景

本 demo 用来模拟一个服务,该服务会定时从数据库中读取版本号,如果版本号发生变化,则会重启服务。

操作步骤

使用 pm2 启动服务

cd pm2
yarn install
yarn start

使用 curl 请求测试服务,观察后面服务重启时是否可以做到 0 停机:

for i in {1..10000}; do echo ${i};curl http://localhost:8080; sleep 0.2; done

观察 pm2 服务日志:

pm2 logs | grep -v from_server

修改数据库中的版本号,观察服务是否可以重启:

sqlite3 pm2/mydb.sqlite
update versions set latest_version = latest_version +1 where id=1;

demo-pm2-watch-db-reload's People

Contributors

nanjingfm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.