>> Deploy

Use Systemd on Linux host FlowCore 2.0



How to install ASP.NET Core 6.0 on Linux
Depending on the Linux distribution you are using, please refer to the official Microsoft documentation to execute the installation command.
Install the .NET SDK or .NET runtime on Ubuntu

(1) Configure the Kestrel Web Server
1.1 Configure Kestrel binding native ports.
Open <runroot/appsettings.json> you can see that Kestrel binds the local address and port <localhost:5000> by default.
localhost equals 127.0.0.1 and uses Kestrel to bind native addresses and ports, which can be used with reverse proxies (Nginx, Apache).
You can customize the port that Kestrel binds (recommended port range 5000-60000) as long as the port is not occupied.
"Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://localhost:5000"
      }
    }
  }

1.2 Start the Kestrel web server in the Linux commands line.
Linux commands
sudo dotnet /FlowCoreApproot/runroot/FlowCore.dll

1.3 Verify that Kestrel is working properly.
Linux commands
curl http://localhost:5000


(2) Configure Kestrel to provide services independently.
This section demonstrates how to configure a Kestrel bound domain name and SSL certificate to provide services independently.
After verifying that the <HTTPS > access is successful, enable <HttpsRedirection> jump.

2.1 Configuring the Kestrel Web Server using <vim > edit <runroot/appsettings.json>.
Linux commands
sudo vim /FlowCoreApproot/runroot/appsettings.json

< how Kestrel-URL > bind
http://localhost:5000 (http listening native NIC loopback address: port 5000, can only be accessed locally)
http://*:5000 (http listens on all IP addresses: 5000 port)
http://office.paicore.com (http listens on all IP addresses of the machine: port 80)
https://office.paicore.com (https listens on all IP addresses of the machine: port 443)
<appsettings.json>The configuration is as follows:
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://office.paicore.com"
      },
      "Https": {
        "Url": "https://office.paicore.com",
        "Certificate": {
          "Path": "/FlowCoreApproot/office.paicore.com.pfx",
          "Password": "Your Password"
        }
      }
    }
  },
 "HttpsRedirection": false,

2.2 Start the Kestrel web server in the Linux commands line.
Linux commands
sudo dotnet /FlowCoreApproot/runroot/FlowCore.dll

2.3 Verify that the HTTP and HTTPS configuration are successful.
Linux commands
curl http://office.paicore.com

Linux commands
curl -4 https://office.paicore.com

2.4 Redirect HTTP to HTTPS
Edit <runroot/appsettings.json> using <vim> and modify <"HttpsRedirection": true>.


(3) Host FlowCore 2.0 with Systemd
3.1 Configure the Linux background service <flowcore.service>. Copy <runroot/flowcore.service> to </etc/systemd/system>.
Linux commands
sudo cp /FlowCoreApproot/runroot/flowcore.service /etc/systemd/system

Use <vim> edit <flowcore.service> to modify the deployment path </FlowCoreApproot > to the actual deployment path.
Linux commands
sudo vim /FlowCoreApproot/runroot/flowcore.service
flowcore.service
[Unit]
Description=FlowCore

[Service]
WorkingDirectory=/FlowCoreApproot/runroot
ExecStart=/usr/bin/dotnet /FlowCoreApproot/runroot/FlowCore.dll

Restart=always
RestartSec=10
SyslogIdentifier=flowcore
User=root
Environment=DOTNET_ROOT=/usr/lib64/dotnet
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

3.2 Start the service <flowcore.service>.
Install the service
Linux commands
sudo systemctl enable /etc/systemd/system/flowcore.service

Start the service
Linux commands
sudo systemctl start flowcore

Stop the service
Linux commands
sudo systemctl stop flowcore

View service status
Linux commands
sudo systemctl status flowcore



© 2023 PaiCore LLC. or its affiliates. All rights reserved.