Skip to content

Commit

Permalink
Added service installation files. Use newer PagerDuty dependency with…
Browse files Browse the repository at this point in the history
… custom HttpClient optimization.
  • Loading branch information
Aldaviva committed Jul 3, 2024
1 parent 38c6d52 commit 4d71f67
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
16 changes: 11 additions & 5 deletions FreshPager/FreshPager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@
<PackageReference Include="jaytwo.FluentUri" Version="0.1.4" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<!-- <PackageReference Include="PagerDuty" Version="1.1.0" /> -->
<PackageReference Include="PagerDuty" Version="1.1.1" />
<PackageReference Include="ThrottleDebounce" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="PagerDuty">
<HintPath>..\..\PagerDuty\PagerDuty\bin\Release\netstandard2.0\PagerDuty.dll</HintPath>
</Reference>
<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('win'))">
<None Update="Install service.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup Condition="$(RuntimeIdentifier.StartsWith('linux'))">
<None Update="freshpager.service">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions FreshPager/Install service.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$binaryPathName = Resolve-Path(join-path $PSScriptRoot "FreshPager.exe")

New-Service -Name "FreshPager" -DisplayName "FreshPager" -Description "When Freshping detects that a check is down, it sends a webhook request to this server, which triggers a PagerDuty alert for the configured service." -BinaryPathName $binaryPathName.Path -DependsOn Tcpip
sc.exe failure FreshPager actions= restart/0/restart/0/restart/0 reset= 86400
19 changes: 19 additions & 0 deletions FreshPager/freshpager.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copy this file to /etc/systemd/system/
#
# Install: sudo systemctl daemon-reload
# Enable auto-start: sudo systemctl enable freshpager.service
# Start: sudo systemctl start freshpager.service
# Check status: sudo systemctl status freshpager.service
# Read logs: sudo journalctl -u freshpager.service

[Unit]
Description=FreshPager

[Service]
Type=notify
ExecStart=/opt/freshpager/freshpager
WorkingDirectory=/opt/freshpager/
Restart=on-failure

[Install]
WantedBy=multi-user.target
14 changes: 14 additions & 0 deletions FreshPager/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@
"System.ServiceProcess.ServiceController": "8.0.0"
}
},
"PagerDuty": {
"type": "Direct",
"requested": "[1.1.1, )",
"resolved": "1.1.1",
"contentHash": "/r+v79RvMTHiiYOmOGlF7etvmWaiEnprZqDiZUO8BGQDXye7H2iDrYHlNvpnV7nILyy2x+ukHht4qreKJ8jJgA==",
"dependencies": {
"Newtonsoft.Json": "13.0.3"
}
},
"ThrottleDebounce": {
"type": "Direct",
"requested": "[2.0.0, )",
Expand Down Expand Up @@ -330,6 +339,11 @@
"resolved": "8.0.0",
"contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g=="
},
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.3",
"contentHash": "HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ=="
},
"System.Diagnostics.DiagnosticSource": {
"type": "Transitive",
"resolved": "8.0.0",
Expand Down

0 comments on commit 4d71f67

Please sign in to comment.