-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Windows support #674
Add Windows support #674
Changes from 147 commits
be691b0
2db5326
a4946e3
81d6633
4cd9afb
79987d4
b7277d2
86d0a76
4bef7b2
286c192
3a82bbd
8b931b1
dbae161
0997bbd
ca3e683
31a02df
9fd163c
20d3f13
b1ad266
50aca45
271c647
f53d48f
159e560
c1be8da
223c94f
5273f53
a2a16ac
acac78d
99eef07
a5fdb33
342119c
9cc9c33
a85a189
e5fd8d2
92bdfe9
4a83158
066c921
7bb3f76
3a0ac15
ca1e84e
ba83a3e
899342a
ebc9d12
9efe112
588a6a5
822aa53
8e4dc9e
f286910
3e3b103
435c982
cbe4e65
dd74b91
bef7995
ec7c350
77897bc
7ba1a39
e4e7e4c
e4165d8
3ae22a5
b8988f0
6f8b171
a28c7f8
848d717
9a8e8fe
d85a38c
73b3d63
90cd888
4a49afe
f362bf0
5f71be9
5a20000
c58f335
1736275
6ef2b36
f44b248
3d03b3f
c9d84cf
ce4726e
29a9098
eabb228
2b6bb2d
6598a4a
f0259ce
e9d8a12
cfd5791
0a2a248
71110f3
ca69b66
8f1a868
0b4f269
9960a40
bc9bb7f
f239933
7d86aca
eefe5b4
0a7854f
dbfae33
0c32008
f6d04be
7aa990b
a8efe8d
04eb101
2b6609c
9f48f1b
1073aaa
2073786
f91b589
a4d2055
b9b07d8
d57fb39
157d86d
ed7fbde
f80aa3b
ef95906
fc9ba35
4197db4
acba044
ca38a23
789c0da
993d0f1
95cfd07
c294c9e
19c16f2
fa8b80b
0e02a93
021f035
effd60a
10cc934
c25db50
5357989
854a5b2
b27bee4
f82edda
c596fe9
3817bf9
fefec5b
24cdace
676741d
21e83ed
e823cfc
1de3b0d
e9c56ed
84cb0af
4448361
b4726df
e9d5dab
3996d5d
7ecec5e
166fee6
d9ef11b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,5 @@ test/config/tmp/* | |
make_dist.sh | ||
Gemfile.local | ||
.ruby-version | ||
*.swp | ||
coverage/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: '{build}' | ||
|
||
install: | ||
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH% | ||
- "%devkit%\\devkitvars.bat" | ||
- ruby --version | ||
- gem --version | ||
- bundle install | ||
build: off | ||
test_script: | ||
- bundle exec rake test TESTOPTS=-v | ||
|
||
environment: | ||
matrix: | ||
- ruby_version: "22-x64" | ||
devkit: C:\Ruby21-x64\DevKit | ||
- ruby_version: "22" | ||
devkit: C:\Ruby21\DevKit | ||
- ruby_version: "21-x64" | ||
devkit: C:\Ruby21-x64\DevKit | ||
- ruby_version: "21" | ||
devkit: C:\Ruby21\DevKit | ||
matrix: | ||
allow_failures: | ||
- ruby_version: "21" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,13 @@ | |
|
||
require 'optparse' | ||
require 'fluent/supervisor' | ||
require 'fluent/log' | ||
require 'fluent/env' | ||
require 'fluent/version' | ||
require 'windows/library' | ||
include Windows::Library | ||
|
||
$fluentdargv = Marshal.load(Marshal.dump(ARGV)) | ||
|
||
op = OptionParser.new | ||
op.version = Fluent::VERSION | ||
|
@@ -34,6 +41,10 @@ | |
opts[:dry_run] = b | ||
} | ||
|
||
op.on('--show-plugin-config=PLUGIN', "Show PLUGIN configuration and exit(ex: input:dummy)") {|plugin| | ||
opts[:show_plugin_config] = plugin | ||
} | ||
|
||
op.on('-p', '--plugin DIR', "add plugin directory") {|s| | ||
opts[:plugin_dirs] << s | ||
} | ||
|
@@ -115,6 +126,19 @@ | |
opts[:gem_install_path] = s | ||
} | ||
|
||
op.on('-x', '--signame INTSIGNAME', "an object name which is used for Windows Service signal (Windows only)") {|s| | ||
opts[:signame] = s | ||
} | ||
|
||
op.on('--reg-winsvc MODE', "install/uninstall as Windows Service. (i: install, u: uninstall) (Windows only)") {|s| | ||
opts[:regwinsvc] = s | ||
} | ||
|
||
op.on('--reg-winsvc-fluentdopt OPTION', "specify fluentd option paramters for Windows Service. (Windows only)") {|s| | ||
opts[:fluentdopt] = s | ||
} | ||
|
||
|
||
(class<<self;self;end).module_eval do | ||
define_method(:usage) do |msg| | ||
puts op.to_s | ||
|
@@ -164,4 +188,48 @@ | |
exit 0 | ||
end | ||
|
||
if winsvcinstmode = opts[:regwinsvc] | ||
FLUENTD_WINSVC_NAME="fluentdwinsvc" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines should be in inside |
||
FLUENTD_WINSVC_DISPLAYNAME="Fluentd Windows Service" | ||
FLUENTD_WINSVC_DESC="Fluentd is an event collector system." | ||
require 'fileutils' | ||
require "win32/service" | ||
require "win32/registry" | ||
include Win32 | ||
|
||
case winsvcinstmode | ||
when 'i' | ||
binary_path = File.join(File.dirname(__FILE__), "..") | ||
ruby_path = "\0" * 256 | ||
GetModuleFileName.call(0,ruby_path,256) | ||
ruby_path = ruby_path.rstrip.gsub(/\\/, '/') | ||
|
||
Service.create( | ||
:service_name => FLUENTD_WINSVC_NAME, | ||
:host => nil, | ||
:service_type => Service::WIN32_OWN_PROCESS, | ||
:description => FLUENTD_WINSVC_DESC, | ||
:start_type => Service::DEMAND_START, | ||
:error_control => Service::ERROR_NORMAL, | ||
:binary_path_name => ruby_path+" -C "+binary_path+" winsvc.rb", | ||
:load_order_group => "", | ||
:dependencies => [""], | ||
:display_name => FLUENTD_WINSVC_DISPLAYNAME | ||
) | ||
when 'u' | ||
Service.delete(FLUENTD_WINSVC_NAME) | ||
else | ||
# none | ||
end | ||
exit 0 | ||
end | ||
|
||
if fluentdopt = opts[:fluentdopt] | ||
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\fluentdwinsvc", Win32::Registry::KEY_ALL_ACCESS) do |reg| | ||
reg['fluentdopt', Win32::Registry::REG_SZ] = fluentdopt | ||
end | ||
exit 0 | ||
end | ||
|
||
require 'fluent/supervisor' | ||
Fluent::Supervisor.new(opts).start |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ def initialize(key, path, unique_id, mode="a+", symlink_path = nil) | |
@path = path | ||
@unique_id = unique_id | ||
@file = File.open(@path, mode, DEFAULT_FILE_PERMISSION) | ||
@file.binmode | ||
@file.sync = true | ||
@size = @file.stat.size | ||
FileUtils.ln_sf(@path, symlink_path) if symlink_path | ||
|
@@ -65,8 +66,20 @@ def open(&block) | |
end | ||
|
||
def mv(path) | ||
File.rename(@path, path) | ||
@path = path | ||
if defined?(Windows) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
pos = @file.pos | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems curious indentations.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed! |
||
@file.close | ||
File.rename(@path, path) | ||
@path = path | ||
@file = File.open(@path, 'rb', DEFAULT_FILE_PERMISSION) | ||
@file.sync = true | ||
@size = @file.size | ||
@file.pos = pos | ||
@size = @file.stat.size | ||
else | ||
File.rename(@path, path) | ||
@path = path | ||
end | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about showing above windows-only options only when
Fluentd.windows?
is true?