Add a documemtation section about how to add a systemd service

This commit is contained in:
Dirk Kuypers
2021-12-16 15:17:21 +01:00
committed by Frederik Carlier
parent 1f9f41b604
commit 14f2bd2db4

View File

@@ -98,6 +98,33 @@ Per default a symlink will by created in /usr/local/bin pointing to your applica
my-app
```
## Creating a Systemd Service
Add a `my-app.service` file to your project containing at least the following
```
[Unit]
Description=My awesome app
[Service]
Type=simple
ExecStart=/usr/local/bin/my-app
[Install]
WantedBy=multi-user.target
```
Add the `my-app.service` file to an `<ItemGroup>` of your `.csproj` with the following content to make sure that it is installed at the right place.
```
<Content Include="my-app.service" CopyToPublishDirectory="PreserveNewest" LinuxFileMode="1755">
<LinuxPath>/etc/systemd/system/my-app.service</LinuxPath>
</Content>
```
Make sure to set the Property `<InstallService>true</InstallService>` in your `.csproj` file.
### Note
You can invoke the packaging tools manually, using a MSBuild target instead of using the a .NET Core CLI tool: