亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

自建windows服務(wù)器如何部署egg應(yīng)用(圖文詳解)

 更新時間:2019年10月17日 13:04:04   作者:xulonglong  
這篇文章主要介紹了自建windows服務(wù)器如何部署egg應(yīng)用的教程,本文圖文并茂給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下

1. 使用IE瀏覽器登陸VPN


2. 遠(yuǎn)程登陸

3. 在服務(wù)器安裝最新的node.js,git等

4. 下載源碼> git clone ****.git

5. npm安裝依賴> cd you-project> npm i

6. 使用egg單進(jìn)程啟動

// 安裝最新的egg包
// 在項(xiàng)目根目錄下新建run.js
const egg = require('egg');
function normalizePort(val) {
 const listenPort = parseInt(val, 10);
 if (isNaN(listenPort)) {
 return val;
 }
 if (listenPort >= 0) {
 return listenPort;
 }
 return false;
}
const port = normalizePort(process.env.PORT) || 3000;
egg.start({ ignoreWarning: true })
 .then(app => {
 app.listen(port);
 app.logger.info(`server running on ${port} ...`);
 });

測試啟動

> node run.js

7. pm2啟動安裝pm2

> npm i pm2 -g

新建pm2啟動文件

module.exports = {
 apps : [{
 name: '****',
 script: 'run.js',

 // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
 args: 'one two',
 instances: 4,
 autorestart: true,
 watch: false,
 max_memory_restart: '4G',
 env: {
 NODE_ENV: 'development',
 },
 env_production: {
 NODE_ENV: 'production',
 APP_URL: '*****',
 DB_HOST: 'localhost',
 DB_PORT: '3306',
 DB_USERNAME: '*****',
 DB_PASSWORD: '*****',
 DB_DATABASE: '*****',
 EGG_SERVER_ENV: '****',
 },
 }],
};

生產(chǎn)環(huán)境啟動

$ pm2 start ecosystem.config.js --env production

測試環(huán)境啟動

$ pm2 start ecosystem.config.js

8. 開放3000端口

參考 http://chabaoo.cn/article/172191.htm

9. 安裝mysql,

參考:http://chabaoo.cn/article/170594.htm

設(shè)置mysql開機(jī)啟動

10. 設(shè)置pm2開機(jī)啟動,使用nssm

查看PM2_HOME, pm2 save

設(shè)置系統(tǒng)環(huán)境變量 PM2_HOME = C:\Users\GYSD\.pm2

驗(yàn)證 echo %PM2_HOME%

創(chuàng)建啟動腳本 pm2_startup.bat

@echo off
set HOMEDRIVE=C:
set PM2_HOME=C:\Users\***\.pm2
@REM Ensure that pm2 command is part of your PATH variable
@REM if you're not sure, add it here, as follow:
set path=C:\Users\****\AppData\Roaming\npm;%path%
@REM Optionally, you can add 'pm2 kill' just before 
@REM resurrect (adding a sleep between 2 commands):
@REM pm2 kill
@REM timeout /t 5 /nobreak > NUL
@REM pm2 resurrect
@REM otherwise, you can simple call resurrect as follow:
pm2 resurrect
echo "Done"

nssm.exe install MyPM2Service

選擇自己的 pm2_startup.bat 路徑

重啟查看

總結(jié)

以上所述是小編給大家介紹的自建windows服務(wù)器如何部署egg應(yīng)用,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

最新評論