🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

lofter-pm2

Package Overview
Dependencies
Maintainers
10
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lofter-pm2

lofter pm2 快速部署

latest
npmnpm
Version
1.3.1
Version published
Weekly downloads
6
-57.14%
Maintainers
10
Weekly downloads
 
Created
Source

lofter-pm2

简化lofter启动pm2服务时的配置,解决overmind环境中同一pm2应用可能会被分配到同一台机器导致应用之间互相关闭的问题。

目录

  • 使用方法
  • 生成文件一览(日志文件)

使用方法

使用 CLI

启动服务

lofter-pm2 start test/server/index.js
lofter-pm2 start 支持的参数
参数名参数描述默认值参数值
mode运行方式developmentdevelopment|production
name自定义服务名称node-server
rootDir运行的目录当前命令运行的目录
启动服务同时附带服务需要的参数
lofter-pm2 start test/server/index.js -- --yourKey=yourValue

暂停服务

lofter-pm2 stop test/server/index.js
lofter-pm2 stop 支持的参数
参数名参数描述默认值参数值
rootDir运行的目录当前命令运行的目录

查看服务

lofter-pm2 status test/server/index.js
lofter-pm2 status 支持的参数
参数名参数描述默认值参数值
rootDir运行的目录当前命令运行的目录

使用 JS API

const lofterPM2 = require('lofter-pm2');

lofterPM2.start({
  mode: 'development', // 可选, development or production, 默认 development
  name: 'server-name', // 可选
  rootDir: process.cwd(), // 可选,默认为命令运行的文件夹
  script: './server/index.js', // 必填,运行的js文件地址,相对于 rootDir
  argv: ['--yourKey','yourValue'] // 可选,附带服务需要的参数
})

lofterPM2.stop({
  rootDir: process.cwd(), // 可选,默认为命令运行的文件夹
  script: './server/index.js', // 必填,运行的js文件地址,相对于 rootDir
})

lofterPM2.status({
  rootDir: process.cwd(), // 可选,默认为命令运行的文件夹
  script: './server/index.js', // 必填,运行的js文件地址,相对于 rootDir
})

生成文件一览

  • 输出的日志文件:'{rootDir}/logs/*.log'
  • 记录运行中服务名: script同级的.running-server-name

FAQs

Package last updated on 27 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts