Home-school H5 deployment instructions

Home-school co-culture V1.0.0

Home-school H5 deployment instructions

For people

Development, testing, operation and maintenance

Development Information

Usually we use in the development of npm run devstart, need to use test on the eve of revolution npm run build && npm run pm2:prodto imitate testing, project deployment of the existing network, to prevent the project do not run up test turn caused the failure.
Script Description

Project Introduction

wave is based on a framework of public Nuxt No. H5 project, using the same configuration page rendering (SSR), network requests using axios, scripts, stylesheets, images are compressed using Vue comes with scaffolding, consolidation, project deployment and use of nodemon pm2.

Project Contents Introduction: About Nuxt.js : -)

├── api                        # 所有请求
├── assets                     # 资源文件
├── components                 # 组件目录
├── layouts                    # 布局目录
├── logs                       # pm2 启动日志
├── middleware                 # 中间件目录
├── mocks                      # 项目mock 模拟数据
├── modules                    # 模块目录
├── pages                      # 页面目录
├── pid                        # pm2 进程日志
├── plugins                    # 插件目录
├── server                     # 启动文件,基于koa
├── static                     # 静态资源
├── store                      # 全局 store管理
├── tests                      # 单元测试
├── utils                      # 工具类
├── .gitignore                 # git 忽略项
├── base.config.js             # 项目基础配置
├── ecosystem.config.js        # pm2 启动文件
├── jest.config.js             # jest 单元测试配置
├── nuxt.config.js             # nuxt 配置
├── tailwind.config.jss        # tailwind 配置
├── package.json               # package.json
└── README.md                  # 项目说明文档

pm2 profile introduction: ecosystem.config.js ( operation and maintenance focus ) PM2 configuration instructions

apps: [{
  name                : 'jiaxiaoclass',
  script              : './server/index.js',
  cwd                 : __dirname,
  args                : '',
  instances           : 1,   						// 集群实例
  'error_file'        : './logs/pm2/error.log',
  'out_file'          : './logs/pm2/out.log',
  'pid_file'          : './pids/pid.pid',
  'merge_logs'        : false,
  'ignore_watch'      : ['node_modules', 'logs', 'pids'],
  autorestart         : true,
  watch               : false,
  exec_mode			  : "cluster"					// 集群模式
  max_memory_restart  : '1G',					    // 溢出重启
  env: {
    NODE_ENV: 'development'
  },
  env_production: {
    NODE_ENV: 'production'
  }
}]

Preparing the Environment

nodejs installation package

Environment to build

For example to linux

  1. NodeJS
  • Installation nodejs: nodejs version is recommended to take v8.11.1, with the development of consistent, download:wget https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz
  • Decompression:tar –xvf node-v8.11.1-linux-x64.tar.xz
  • Delete archive:rm –rf node-v8.11.1-linux-x64.tar.xz
  • Nodejs see if the installation was successful: node –v
    Here Insert Picture Description
  1. PM2
  • Global installed pm2 (pm2 can monitor the operation of the project)npm i pm2 –g
  • Check whether the installation is successful pm2 pm2 -v
    Here Insert Picture Description

Project deployment

Run node module installation command: npm install

Start the service npm run build, testing: npm run pm2:testO & M:npm run pm2:prod

Here Insert Picture Description
Here Insert Picture DescriptionView real-time log information, there will be a brief vacuum,pm2 log jiaxiaoclass
Here Insert Picture Description

View Log

In the wave of the log file logs directory, which tests to see /pm2/out-xx.log , operation and maintenance view yyyy-MM-dd.log , inconsistent log file.
Such as:
test: tail –n 100 –f logs/pm2/out-0.log
operation and maintenance: tail –n 100 –f logs/2018-04-03.log
at the same time thanks to the pm2 deployment project, log also can run in any directory:
pm2 logs (due to the existing network log stored in the yyyy-MM-dd.log file, this command is invalid for the operation and maintenance)

PM2 Common Command Reference

Published 19 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_41597258/article/details/103901642