Skip to content

Commit dabb717

Browse files
committed
msi: fix slow start issue on Windows
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 <hayashi@clear-code.com>
1 parent 1bd0d76 commit dabb717

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

fluent-package/Gemfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ if ENV["INSTALL_GEM_FROM_LOCAL_REPO"]
3232
source FLUENTD_LOCAL_GEM_REPO do
3333
gem "fluentd"
3434
end
35+
# Bundle forked version of win32-service until
36+
# https://github.com/chef/win32-service/pull/85 is merged.
37+
# This workaround should be applied to fluent-package not to block starting
38+
# fluentdwinsvc service on Windows. See
39+
# https://github.com/fluent/fluent-package-builder/issues/618
40+
# NOTE: platforms: does not work in source ... do block
41+
gem "win32-service", platforms: [:mingw, :x64_mingw]
3542
else
3643
# Lock to specific revision
3744
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3845
gem "fluentd", github: "fluent/fluentd", ref: FLUENTD_REVISION
46+
gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw]
3947
end
4048

4149
# plugin gems
@@ -81,7 +89,8 @@ gem "ffi-win32-extensions", "1.0.4", platforms: windows_platforms
8189
gem "nokogiri", "1.15.5", platforms: windows_platforms
8290
gem "win32-event", "0.6.3", platforms: windows_platforms
8391
gem "win32-ipc", "0.7.0", platforms: windows_platforms
84-
gem "win32-service", "2.3.2", platforms: windows_platforms
92+
# Use forked version of win32-service. See INSTALL_GEM_FROM_LOCAL_REPO
93+
#gem "win32-service", "2.3.2", platforms: windows_platforms
8594
gem "winevt_c", "0.10.1", platforms: windows_platforms
8695
gem "win32-eventlog", "0.6.7", platforms: windows_platforms
8796
gem "fluent-plugin-parser-winevt_xml", "0.2.6", platforms: windows_platforms

fluent-package/Gemfile.lock

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
GIT
2+
remote: https://github.com/fluent-plugins-nursery/win32-service
3+
revision: cfcc2007b3843127329d6a7307a62a927a714327
4+
branch: fluent-package
5+
specs:
6+
win32-service (2.3.2)
7+
ffi
8+
ffi-win32-extensions
9+
110
GIT
211
remote: https://github.com/fluent/fluentd
312
revision: d3cf2e0f95a0ad88b9897197db6c5152310f114f
@@ -257,9 +266,6 @@ GEM
257266
ffi
258267
win32-ipc (0.7.0)
259268
ffi
260-
win32-service (2.3.2)
261-
ffi
262-
ffi-win32-extensions
263269
winevt_c (0.10.1)
264270
yajl-ruby (1.4.3)
265271
zip-zip (0.3)
@@ -333,7 +339,7 @@ DEPENDENCIES
333339
win32-event (= 0.6.3)
334340
win32-eventlog (= 0.6.7)
335341
win32-ipc (= 0.7.0)
336-
win32-service (= 2.3.2)
342+
win32-service!
337343
winevt_c (= 0.10.1)
338344
yajl-ruby (= 1.4.3)
339345

fluent-package/Rakefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class DownloadTask
177177
attr_reader :file_jemalloc_source
178178
attr_reader :file_ruby_source, :file_ruby_installer_x64
179179
attr_reader :file_fluentd_archive
180+
attr_reader :file_win32_service_archive
180181
attr_reader :files_ruby_gems
181182
attr_reader :file_openssl_source
182183

@@ -199,6 +200,7 @@ class DownloadTask
199200
define_jemalloc_file
200201
define_ruby_files
201202
define_fluentd_archive
203+
define_win32_service_archive if windows?
202204
define_gem_files
203205
define_openssl_file
204206

@@ -210,7 +212,8 @@ class DownloadTask
210212
task :ruby => [@file_ruby_source, @file_ruby_installer_x64]
211213

212214
desc "Clone fluentd repository and create a tarball"
213-
task :fluentd => @file_fluentd_archive
215+
task :fluentd => windows? ? [@file_fluentd_archive, @file_win32_service_archive] :
216+
[@file_fluentd_archive]
214217

215218
desc "Download ruby gems"
216219
task :ruby_gems => @files_ruby_gems
@@ -318,6 +321,21 @@ class DownloadTask
318321
end
319322
end
320323

324+
def define_win32_service_archive
325+
@file_win32_service_archive = File.join(DOWNLOADS_DIR, "win32-service.tar.gz")
326+
file @file_win32_service_archive do
327+
ensure_directory(DOWNLOADS_DIR) do
328+
dirname = "win32-service"
329+
rm_rf(dirname) if File.exist?(dirname)
330+
sh("git", "clone", "https://github.com/fluent-plugins-nursery/win32-service.git")
331+
cd("win32-service") do
332+
sh("git", "checkout", "fluent-package")
333+
end
334+
sh(*tar_command, "cvfz", "#{dirname}.tar.gz", dirname)
335+
end
336+
end
337+
end
338+
321339
def define_gem_files
322340
paths = []
323341
Dir.glob("#{DOWNLOADS_DIR}/*.gem") do |path|
@@ -436,6 +454,15 @@ class BuildTask
436454
setup_local_gem_repo
437455
install_gemfiles
438456
end
457+
if windows?
458+
archive_path = @download_task.file_win32_service_archive
459+
sh(*tar_command, "xvf", archive_path, *tar_options) unless File.exist?("win32-service")
460+
cd("win32-service") do
461+
sh("rake", "build")
462+
setup_local_gem_repo
463+
install_gemfiles
464+
end
465+
end
439466
end
440467
end
441468

0 commit comments

Comments
 (0)