Skip to content

Commit

Permalink
msi: fix slow start issue on Windows
Browse files Browse the repository at this point in the history
Until chef/win32-service#85 is merged,

This fix should be applied to fluent-package not to block starting
fluentdwinsvc service on Windows.

See #618

Closes: #630

NOTE: even though just putting the following line
does not install forked version of win32-service, so
install it explicitly as same as fluentd gem.

  gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw]

Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
  • Loading branch information
kenhys committed Mar 11, 2024
1 parent 1bd0d76 commit fa99bc3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
10 changes: 9 additions & 1 deletion fluent-package/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ if ENV["INSTALL_GEM_FROM_LOCAL_REPO"]
# into managed Gemfile.lock
source FLUENTD_LOCAL_GEM_REPO do
gem "fluentd"
# Bundle forked version of win32-service until
# https://github.com/chef/win32-service/pull/85 is merged.
# This workaround should be applied to fluent-package not to block starting
# fluentdwinsvc service on Windows. See
# https://github.com/fluent/fluent-package-builder/issues/618
gem "win32-service"
end
else
# Lock to specific revision
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "fluentd", github: "fluent/fluentd", ref: FLUENTD_REVISION
gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw]
end

# plugin gems
Expand Down Expand Up @@ -81,7 +88,8 @@ gem "ffi-win32-extensions", "1.0.4", platforms: windows_platforms
gem "nokogiri", "1.15.5", platforms: windows_platforms
gem "win32-event", "0.6.3", platforms: windows_platforms
gem "win32-ipc", "0.7.0", platforms: windows_platforms
gem "win32-service", "2.3.2", platforms: windows_platforms
# Use forked version of win32-service. See INSTALL_GEM_FROM_LOCAL_REPO
#gem "win32-service", "2.3.2", platforms: windows_platforms
gem "winevt_c", "0.10.1", platforms: windows_platforms
gem "win32-eventlog", "0.6.7", platforms: windows_platforms
gem "fluent-plugin-parser-winevt_xml", "0.2.6", platforms: windows_platforms
Expand Down
29 changes: 28 additions & 1 deletion fluent-package/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class DownloadTask
attr_reader :file_jemalloc_source
attr_reader :file_ruby_source, :file_ruby_installer_x64
attr_reader :file_fluentd_archive
attr_reader :file_win32_service_archive
attr_reader :files_ruby_gems
attr_reader :file_openssl_source

Expand All @@ -191,6 +192,7 @@ class DownloadTask
@file_ruby_source,
@file_ruby_installer_x64,
@file_fluentd_archive,
@file_win32_service_archive,
*@files_ruby_gems
]
end
Expand All @@ -199,6 +201,7 @@ class DownloadTask
define_jemalloc_file
define_ruby_files
define_fluentd_archive
define_win32_service_archive
define_gem_files
define_openssl_file

Expand All @@ -210,7 +213,7 @@ class DownloadTask
task :ruby => [@file_ruby_source, @file_ruby_installer_x64]

desc "Clone fluentd repository and create a tarball"
task :fluentd => @file_fluentd_archive
task :fluentd => [@file_fluentd_archive, windows? ? @file_win32_service_archive : nil]

desc "Download ruby gems"
task :ruby_gems => @files_ruby_gems
Expand Down Expand Up @@ -318,6 +321,21 @@ class DownloadTask
end
end

def define_win32_service_archive
@file_win32_service_archive = File.join(DOWNLOADS_DIR, "win32-service.tar.gz")
file @file_win32_service_archive do
ensure_directory(DOWNLOADS_DIR) do
dirname = "win32-service"
rm_rf(dirname) if File.exist?(dirname)
sh("git", "clone", "https://github.com/fluent-plugins-nursery/win32-service.git")
cd("win32-service") do
sh("git", "checkout", "fluent-package")
end
sh(*tar_command, "cvfz", "#{dirname}.tar.gz", dirname)
end
end
end

def define_gem_files
paths = []
Dir.glob("#{DOWNLOADS_DIR}/*.gem") do |path|
Expand Down Expand Up @@ -436,6 +454,15 @@ class BuildTask
setup_local_gem_repo
install_gemfiles
end
if windows?
archive_path = @download_task.file_win32_service_archive
sh(*tar_command, "xvf", archive_path, *tar_options) unless File.exist?("win32-service")
cd("win32-service") do
sh("rake", "build")
setup_local_gem_repo
install_gemfiles
end
end
end
end

Expand Down

0 comments on commit fa99bc3

Please sign in to comment.