lock file feature
This commit is contained in:
parent
01b45aaab8
commit
21f4f9dcab
5 changed files with 50 additions and 6 deletions
26
includes/ps1/lockfile.ps1
Normal file
26
includes/ps1/lockfile.ps1
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
function new-lock {
|
||||||
|
if ($env:temp) {
|
||||||
|
$lockFile = Join-Path -Path $env:temp -ChildPath 'lockfile_pubg.lock'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$lockFile = "/tmp/lockfile_pubg.lock"
|
||||||
|
}
|
||||||
|
if (Test-Path -Path $lockFile) {
|
||||||
|
Write-Host "Job is already running."
|
||||||
|
Exit
|
||||||
|
}
|
||||||
|
New-Item -ItemType File -Path $lockFile | Out-Null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
function remove-lock {
|
||||||
|
if ($env:temp) {
|
||||||
|
$lockFile = Join-Path -Path $env:temp -ChildPath 'lockfile_pubg.lock'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$lockFile = "/tmp/lockfile_pubg.lock"
|
||||||
|
}
|
||||||
|
Remove-Item -Path $lockFile
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
. .\..\includes\ps1\lockfile.ps1
|
||||||
|
|
||||||
|
new-lock
|
||||||
|
|
||||||
if ($PSScriptRoot.length -eq 0) {
|
if ($PSScriptRoot.length -eq 0) {
|
||||||
$scriptroot = Get-Location
|
$scriptroot = Get-Location
|
||||||
|
|
@ -5,6 +8,9 @@ if ($PSScriptRoot.length -eq 0) {
|
||||||
else {
|
else {
|
||||||
$scriptroot = $PSScriptRoot
|
$scriptroot = $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Read the content of the file as a single string
|
# Read the content of the file as a single string
|
||||||
$fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw
|
$fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw
|
||||||
|
|
||||||
|
|
@ -93,3 +99,5 @@ $playermatches += [PSCustomObject]@{
|
||||||
}
|
}
|
||||||
|
|
||||||
$player_matches | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_matches.json"
|
$player_matches | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_matches.json"
|
||||||
|
|
||||||
|
remove-lock
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
. .\..\includes\ps1\lockfile.ps1
|
||||||
|
|
||||||
|
new-lock
|
||||||
|
|
||||||
if ($PSScriptRoot.length -eq 0) {
|
if ($PSScriptRoot.length -eq 0) {
|
||||||
$scriptroot = Get-Location
|
$scriptroot = Get-Location
|
||||||
|
|
@ -173,3 +176,4 @@ foreach ($file in $difference) {
|
||||||
Remove-Item -Path "$scriptroot/../data/telemetry_cache/$file"
|
Remove-Item -Path "$scriptroot/../data/telemetry_cache/$file"
|
||||||
}
|
}
|
||||||
write-output "Operation complete"
|
write-output "Operation complete"
|
||||||
|
remove-lock
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
. .\..\includes\ps1\lockfile.ps1
|
||||||
|
|
||||||
|
new-lock
|
||||||
if($PSScriptRoot.length -eq 0){
|
if($PSScriptRoot.length -eq 0){
|
||||||
$scriptroot = Get-Location
|
$scriptroot = Get-Location
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -46,3 +48,4 @@ $clandata | Add-Member -Name "updated" -MemberType NoteProperty -Value $formatte
|
||||||
$clandata | convertto-json -Depth 100 | out-file "$scriptroot/../data/claninfo.json"
|
$clandata | convertto-json -Depth 100 | out-file "$scriptroot/../data/claninfo.json"
|
||||||
|
|
||||||
$clandata | convertto-json -Depth 100
|
$clandata | convertto-json -Depth 100
|
||||||
|
remove-lock
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
|
. .\..\includes\ps1\lockfile.ps1
|
||||||
|
|
||||||
|
new-lock
|
||||||
if ($PSScriptRoot.length -eq 0) {
|
if ($PSScriptRoot.length -eq 0) {
|
||||||
$scriptroot = Get-Location
|
$scriptroot = Get-Location
|
||||||
}
|
}
|
||||||
|
|
@ -123,3 +125,4 @@ $lifetimestats['updated'] = $formattedString
|
||||||
|
|
||||||
|
|
||||||
$lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json"
|
$lifetimestats | convertto-json -Depth 100 | out-file "$scriptroot/../data/player_lifetime_data.json"
|
||||||
|
remove-lock
|
||||||
Loading…
Add table
Add a link
Reference in a new issue