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 fluent#618

Closes: fluent#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 <[email protected]>
  • Loading branch information
kenhys committed Mar 12, 2024
1 parent 1bd0d76 commit dabb717
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
11 changes: 10 additions & 1 deletion fluent-package/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ if ENV["INSTALL_GEM_FROM_LOCAL_REPO"]
source FLUENTD_LOCAL_GEM_REPO do
gem "fluentd"
end
# 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
# NOTE: platforms: does not work in source ... do block
gem "win32-service", platforms: [:mingw, :x64_mingw]
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 +89,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
14 changes: 10 additions & 4 deletions fluent-package/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/fluent-plugins-nursery/win32-service
revision: cfcc2007b3843127329d6a7307a62a927a714327
branch: fluent-package
specs:
win32-service (2.3.2)
ffi
ffi-win32-extensions

GIT
remote: https://github.com/fluent/fluentd
revision: d3cf2e0f95a0ad88b9897197db6c5152310f114f
Expand Down Expand Up @@ -257,9 +266,6 @@ GEM
ffi
win32-ipc (0.7.0)
ffi
win32-service (2.3.2)
ffi
ffi-win32-extensions
winevt_c (0.10.1)
yajl-ruby (1.4.3)
zip-zip (0.3)
Expand Down Expand Up @@ -333,7 +339,7 @@ DEPENDENCIES
win32-event (= 0.6.3)
win32-eventlog (= 0.6.7)
win32-ipc (= 0.7.0)
win32-service (= 2.3.2)
win32-service!
winevt_c (= 0.10.1)
yajl-ruby (= 1.4.3)

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 @@ -199,6 +200,7 @@ class DownloadTask
define_jemalloc_file
define_ruby_files
define_fluentd_archive
define_win32_service_archive if windows?
define_gem_files
define_openssl_file

Expand All @@ -210,7 +212,8 @@ 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 => windows? ? [@file_fluentd_archive, @file_win32_service_archive] :
[@file_fluentd_archive]

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 dabb717

Please sign in to comment.