This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3444|Reply: 1

[Source] Start the Guardian ASP.NET Core app with PM2

[Copy link]
Posted on 2024-3-21 19:56:00 | | | |
PM2 is a daemon manager that will help you manage and keep your applications online. Getting started with PM2 is straightforward, and it is available in a simple and intuitive CLI that can be installed via NPM.

PM2 document address:The hyperlink login is visible.
GitHub address:The hyperlink login is visible.

Other process guards: Forever, Pm2, Supervisor, Systemd, Daemontools, review:

Supervisor installation configuration for CentOS
https://www.itsvse.com/thread-3719-1-1.html

Centos 7 .Net core background daemon supervisor tutorial
https://www.itsvse.com/thread-4870-1-1.html

Starting supervisor: Error: Another program is already listening on a port th...
https://www.itsvse.com/thread-3720-1-1.html

First, log in to the server and install pm2 using npm with the following command:



PM2 common commands

commandillustrate
pm2 startupSet PM2 to boot auto-boot
pm2 unstartupRemove PM2 boot auto-boot
pm2 saveSave the current process to boot and start auto
pm2 start <进程启动命令> [--name <进程名>]Launch the app
pm2 listDisplays all process statuses
pm2 monitMonitor the process
pm2 logs [process id or name]Display process logs
pm2 stop [all]Stop [all] processes
pm2 restart [all]Restart [all] processes
pm2 delete [<进程名或者id>,all]Delete the specified [all] process
pm2 info [process id or name]View app information


Then, create a new ASP.NET Core website, run the publishing settings independently, and upload the release package to the service/root/testfolder. (omitted)

And give the ASP.NET Core startup permission to execute with the following command:



If you do not grant the app permission to execute, you will not be able to start the app using PM2 with the following error:

2024-03-21T18:13:29: PM2 error: app=demo id=0 does not have a pid
2024-03-21T18:13:37: PM2 log: App [demo:0] starting in -fork mode-
2024-03-21T18:13:37: PM2 log: App [demo:0] online
2024-03-21T18:13:37: PM2 error: Error: spawn /root/test/WebApplication1 EACCES
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
2024-03-21T18:13:37: PM2 error: Error caught while calling pidusage
2024-03-21T18:13:37: PM2 error: TypeError: One of the pids provided is invalid

Create a new web.json configuration file on the server (the configuration file supports JavaScript, JSON, or YAML formats) as follows:



Start the app with pm2 with the following command:



As shown below:



Try accessing the site as shown below:



(End)




Previous:Relational database design: a popular understanding of the three paradigms
Next:C# programming uses the Override and New keywords to distinguish between them
 Landlord| Posted on 2024-3-21 19:56:58 |
Other JSON configuration files:



More configuration references:The hyperlink login is visible.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com