Expressjs 生成的NodeJS網站,用「npm start」可以啟動訪問,forever 或者 pm2 可以啟動,但是無法訪問?

expressjs 版本:4.2.0

npm 版本 1.4.9

NodeJS 版本:v0.10.28

pm2 版本:0.8.15


pm2 start ./bin/www


4&>使用用forever守護node 進程:

1.forever -c "npm start" ./ (為路徑名稱)

2.forever list (查看進程名稱)

3.forever stop [0]停止進程

4.ps aux | grep "forever|node" (查看完使用 kill -9 pid)

5&>pm2啟動:

pm2 start "/usr/local/bin/npm" --name "law" -- start .

這個的具體使用開api文檔吧

能做的只有這麼多了


同樣遇到這個問題,不知道樓主有沒有解決呢?


沒遇到過這個問題,埠有沒有正確,forever或者pm2有沒有正常啟動


到項目目錄,cd bin,forever start www就可以了,別忘了裝forever-monitor


首先確認程序是否正常啟動,然後通過netstat -tpnl 查看監聽的埠


你先看下 package.json里的啟動腳本是怎樣的, 即 npm start的啟動腳本, 對比下看看forever或pm2的啟動腳本缺了啥


StrongLoop Process Manager

StrongLoop Process Manager (StrongLoop PM) is a production process manager for Node.js applications with built-in load balancing, monitoring, multi-host deployment, and a graphical console. It enables you to:

  • Build, package, and deploy your Node application to a local or remote system.
  • View CPU profiles and heap snapshots to optimize performance and diagnose memory leaks.
  • Keep processes and clusters alive forever.
  • View performance metrics on your application.
  • Easily manage multi-host deployments with Nginx integration.
  • Unify multiple StrongLoop PMs to a distributed microservices runtime managed from Arc.

You can work with StrongLoop PM using a powerful CLI tool, slc, or a graphical tool, Arc. It』s open source, with professional support provided by StrongLoop.

For more information, see http://strong-pm.io/.

Full documentation:

  • Operating Node apps (StrongLoop documentation)
  • Using StrongLoop Process Manager.

Installation

$ [sudo] npm install -g strongloop

Basic use

$ cd my-app
$ slc start

View status of Process Manager and all deployed apps:

$ slc ctl
Service ID: 1
Service Name: my-app
Environment variables:
No environment variables defined
Instances:
Version Agent version Cluster size
4.1.13 1.5.14 4
Processes:
ID PID WID Listening Ports Tracking objects? CPU profiling?
1.1.57692 57692 0
1.1.57693 57693 1 0.0.0.0:3001
1.1.57694 57694 2 0.0.0.0:3001
1.1.57695 57695 3 0.0.0.0:3001
1.1.57696 57696 4 0.0.0.0:3001

List all apps (services) under management:

$ slc ctl ls
Id Name Scale
1 my-app 1

Stop an app:

$ slc ctl stop my-app

Restart an app:

$ slc ctl restart my-app

You can also 「soft restart,」 which gives worker processes a grace period to close existing connections, then restarts the current application:

$ slc ctl soft-restart my-app

To remove an app from management:

$ slc ctl remove my-app


推薦閱讀:

前端開發中的一些框架,插件,git使用真的很重要麼?
如何在docker里部署nodejs?
Node.js新手在哪兒找小項目練手?
前端小白迷茫,求指導?
PHP和Node.js哪個更爽?

TAG:Nodejs | Express框架 |