windows系统发布WorkerService到Linux系统
时间: 2023-03-21 21:00:30 浏览: 87
windows与Linux连接工具
To publish a Worker Service from a Windows system to a Linux system, you will need to follow these steps:
1. Compile your .NET Core Worker Service for Linux platform using a command like `dotnet publish -r linux-x64`.
2. Copy the published output folder to your Linux system.
3. On your Linux system, install .NET Core Runtime for the appropriate version and platform if it's not already installed.
4. Navigate to the folder where you copied the published output and run the command `dotnet YourService.dll` to start the Worker Service.
5. You can also create a service to run the Worker Service in the background by creating a systemd service file.
Here's an example of a systemd service file:
```
[Unit]
Description=YourService
[Service]
WorkingDirectory=/path/to/your/service
ExecStart=/usr/bin/dotnet /path/to/your/service/YourService.dll
Restart=always
# Restart service after 10 seconds if it crashes:
RestartSec=10
SyslogIdentifier=YourService
User=youruser
[Install]
WantedBy=multi-user.target
```
You would need to modify the paths in the above example to match the location of your Worker Service and the user under which you want to run the service. Then, save the file as `/etc/systemd/system/YourService.service`, and run the command `sudo systemctl enable YourService.service` to enable the service at startup. Finally, you can start the service by running `sudo systemctl start YourService.service`.
阅读全文