1. Log in to VPN using IE browser 2. Remote login 3. Install the latest node.js, git, etc. on the server 4. Download source code 5. npm install dependencies 6. Use egg single process startup // Install the latest egg package // Create a new run.js in the project root directory 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} ...`); }); Test Startup 7. pm2 starts and installs pm2 Create a new pm2 startup file 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: '****', }, }], }; Production environment startup $ pm2 start ecosystem.config.js --env production Test environment startup $ pm2 start ecosystem.config.js 8. Open port 3000 Reference https://www.jb51.net/article/172191.htm 9. Install mysql, Reference: https://www.jb51.net/article/170594.htm Set mysql to start at boot 10. Set pm2 to start at boot and use nssm View PM2_HOME, pm2 save Set the system environment variable PM2_HOME = Verify echo %PM2_HOME% Create a startup script 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 simply call resurrect as follow: pm2 resurrect echo "Done" nssm.exe install MyPM2Service Choose your own Restart to view Summarize The above is my introduction on how to deploy egg applications on self-built Windows servers. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: In-depth understanding of MySQL master-slave replication thread state transition
>>: Understand the initial use of redux in react in one article
Table of contents 1. First, use pycharm to create...
Preface Today I installed MySQL and found that th...
Absolute, relative and fixed in position position...
Recently, I want to regularly back up important i...
Table of contents 1. Use SVG 2. Use fontAwesome 3...
1. What is Docker Secret 1. Scenario display We k...
Preface: In some previous articles, we often see ...
Table of contents Installation-free version of My...
HTML is made up of tags and attributes, which are...
This article records the detailed installation pr...
Win10 system locally installed MySQL8.0.20, perso...
One line command docker run -d \ -v /share:/home/...
Table of contents introduction Ideas Establish ID...
After the previous two chapters, do you have a ne...
When we write pages, we sometimes find that the C...