我目前将以下内容作为 Windows 服务的“可执行文件路径”。
我想知道如何将它转换为命令行应用程序,以便我可以交互式地调试它。
Windows 服务可执行文件路径:“C:\LONG_PATH_1\ruby\bin\rubyXXXX_console.exe”“C:\LONGPATH_2\windows_script.rb”
windows_script.rb 如下:
# console_windows.rb
#
# Windows-specific service code.
# redirect stdout / stderr to file, else Windows Services will crash on output
$stdout.reopen File.open(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..',
'log', 'XXXX_console.output')), 'a')
$stderr.reopen $stdout
$stdout.sync = true
$stderr.sync = true
require File.join(File.dirname(File.expand_path(__FILE__)),"script_helper.rb")
require 'rubygems'
require 'win32/daemon'
include Win32
class BackgroundWindowsDaemon < Daemon
def service_init
# Do startup in service_main so that Windows Services doesn't timeout during startup
end
def service_main
BackgroundScriptHelper.request_start
BackgroundScriptHelper.monitor
end
def service_stop
BackgroundScriptHelper.request_stop
end
end
BackgroundWindowsDaemon.new.mainloop