บทความ

Run a Npm Start Script With PM2

รูปภาพ
  How to Run a Npm Start Script With PM2 August 02, 2019 / NodeJS Are you looking for a way to run  npm start  scripts with  PM2 ? Or how to to do so while also using the options commands with it as well? In this article, we will go through some examples that will help you achieve this. If you haven't already, you can install PM2 globally on your machine with this command: Command Copy npm install pm2 -g Once you have the NPM package installed, you'll be good to go with using the examples in this article! Table Of Contents NPM Start Script NPM Start Script With the App Name Option NPM Start Script With Multiple Options NPM Start Script To run the  npm start  script with PM2, you can use the following command (make sure you call the command from inside your project folder): Command Copy pm2 start npm -- start And you should see a similar output in your command prompt: Output [PM2] Starting /usr/bin/npm in fork_mode (1 instance) [PM2] Done. ┌──────────┬────┬──────┬──────┬────────

NPX และ NVM

NPX จัดการ ​ module ใน​project nvm จัดการเวอร์ชันของ​ node ครับ

fastify

http://www.lib4dev.in/info/davidedantonio/create-fastify-app/168822858   create-fastify-app pm2 start -i 0 npm -- start t's working fine on CentOS 7 PM2 version 4.2.1 let's take two scenarios: 1. npm start  //server.js pm2 start "npm -- start" -- name myMainFile 2. npm run main  //main.js pm2 start "npm -- run main" -- name myMainFile ame "app name" -- start

node.js กับ pm2

วิธีการ run node.js บน server ด้วย pm2 ติดตั้งโปรแกรม npm install pm2 -g รันโปรแกรม ที่ต้องการพร้อมการกำหนดชื่อ pm2 start index.js -n "Hello Wold PM2" รันโปรแกรม แบบ  cluster pm2 start index.js -i 2 // หมายถึง ทำเป็น cluster 2 ตัว หรือ pm2 start index.js -i max // หมายถึงทำเป็น cluster มากที่สุดเท่าที่ cpu รองรับ รันโปรแกรมทุกครั้งหลังจาก reboot  linux pm2 startup // หมายถึงเมื่อมีการ start server ให้ program เรา start ด้วย pm2 save // หมายถึงให้ pm2 เก็บข้อมูลทั้งหมดเพื่อใช้ตอน start https://medium.com/pnpsolution/%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%81%E0%B8%B2%E0%B8%A3-run-node-js-%E0%B8%9A%E0%B8%99-server-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-pm2-fd66c1e54b60