Running an ASP. NET core site on Linux as a service

Source: Internet
Author: User
Tags dotnet

To run an ASP. NET Core site on a Linux server in a build environment, the first problem is to run the ASP. NET core site as a service, so that the site can run automatically even if the server restarts.

There are powerful PM2 in node. js, and. NET core has nothing to do with its own hands-on implementation. Groping for a night, and finally using the INITCTL command based on the Linux upstart implementation, in this blog post to share (the experiment with the Linux server is Ubuntu).

First create a service configuration file in the/etc/init/directory, such as this is/etc/init/dotnet-app.conf, and add the following to the file:

Description     "Set System Dotnet-app" Start on RunLevel [2345]taskscriptcd/data/aboutus && sudo dotnet run End Script

The bold part is the command that runs the ASP. NET Core site.

Then start the service with the following command:

Initctl Start Dotnet-app

Note: If the "Initctl:job failed to start" error occurs, you can view the corresponding error log in the "/var/log/upstart/" directory, for example, this is/var/log/upstart/dotnet-app.log.

Then use the following command to see the service running:

# initctl Status Dotnet-appdotnet-app start/running, Process 862

"Start/running" indicates that the service started successfully, and then the ASP. NET core site is normally accessible.

Finally reboot the Linux server verify that the reboot command restarts the server, after the server is started, the ASP. NET Core site is also accessible, done.

Running an ASP. NET core site on Linux as a service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.