Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msi: guard duplicated instance #622

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions fluent-package/msi/assets/fluentd.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,36 @@ set FLUENT_PACKAGE_TOPDIR=!FLUENT_PACKAGE_TOPDIR:\=/!

set PATH=%FLUENT_PACKAGE_TOPDIR%bin;%PATH%
set PATH=%FLUENT_PACKAGE_TOPDIR%;%PATH%
set "FLUENT_CONF=%FLUENT_PACKAGE_TOPDIR%/etc/fluent/fluentd.conf"
set "FLUENT_PLUGIN=%FLUENT_PACKAGE_TOPDIR%/etc/fluent/plugin"
set "FLUENT_PACKAGE_VERSION=%FLUENT_PACKAGE_TOPDIR%/bin/fluent-package-version.rb"
set "FLUENT_CONF=%FLUENT_PACKAGE_TOPDIR%etc/fluent/fluentd.conf"
set "FLUENT_PLUGIN=%FLUENT_PACKAGE_TOPDIR%etc/fluent/plugin"
set "FLUENT_PACKAGE_VERSION=%FLUENT_PACKAGE_TOPDIR%bin/fluent-package-version.rb"
set FLUENT_FORCE_RUN=0
set FLUENT_ARGS=
for %%p in (%*) do (
if "%%p"=="--version" (
ruby "%FLUENT_PACKAGE_VERSION%"
goto last
)
if "%%p"=="--force-running-multiple-instance" (
set /a FLUENT_FORCE_RUN=1
) else (
set "FLUENT_ARGS=!FLUENT_ARGS! %%p"
)
)
"%FLUENT_PACKAGE_TOPDIR%/bin/fluentd" %*

@rem Abort if the fluentdwinsvc service is running without --force option.
sc query fluentdwinsvc | findstr RUNNING > nul
if !ERRORLEVEL! equ 0 (
if %FLUENT_FORCE_RUN% equ 1 (
goto noguard
) else (
echo Error: can't start duplicate Fluentd instance. Use --force-running-multiple-instance option explicitly.
exit /b 2
)
)

:noguard
"%FLUENT_PACKAGE_TOPDIR%/bin/fluentd" %FLUENT_ARGS%
endlocal

:last
8 changes: 8 additions & 0 deletions fluent-package/msi/update-from-v4-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ $output_files_after_sleep = Get-ChildItem "C:\\opt\\td-agent\\output"
If ($output_files_after_sleep.Count -le $output_files.Count) {
[Environment]::Exit(1)
}

# Test: Abort if FLUENT_CONF is conflict with fluentdopt
$proc = Start-Process "C:\\opt\\fluent\\fluentd.bat" -Wait -NoNewWindow -PassThru
if ($proc.ExitCode -ne 2) {
Write-Host "Failed to abort when already fluentdwinsvc service is running"
[Environment]::Exit(1)
}
Write-Host "Succeeded to abort if trying to launch multiple Fluentd instance"
Loading