Project

General

Profile

Bug #10378

smart-proxy service doesn't start on windows

Added by Dmitri Dolguikh almost 4 years ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Category:
Core
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

```
C:\AA\foreman\smart\bin>net start "smart proxy"
The service is not responding to the control function.

More help is available by typing NET HELPMSG 2186.
```

No logs are created. I don't know what is happening at all :/


Related issues

Related to Smart Proxy - Support #10098: Does anyone have an updated procedure to install smart proxy on a Windows Server 2008 R2 OS?Resolved2015-04-08
Related to Website - Feature #12006: RFE: Be more specific about smart-proxy installation in windowsClosed2015-09-30

Associated revisions

Revision 8e19663f (diff)
Added by Dmitri Dolguikh about 3 years ago

Fixes #10378: smart-proxy service starts on windows now

History

#1 Updated by Benjamin Papillon over 3 years ago

With some trials and tests, we nailed the error to the use of bundler vs bundler_ext.
When using the former the service starts. when using bundle, ruby 1.9.3 complains about not finding its dependencies.

The work around :
- prerequisites : the smart proxy service should be registered with <smartproxy dir>\bin\smart-proxy-win-service
- In the smart proxy directory, copy gemfile to gemfile.in
- Install bundler_ext gem

gem install bundler_ext

Here is the file I used as bin\smart-proxy-win-service
Please be sure to update 1st line and logfile path.

#!c:\ruby193\bin\ruby.exe
$LOAD_PATH.unshift(*Dir[File.expand_path("../../lib", __FILE__), File.expand_path("../../modules", __FILE__)])

require 'rubygems'
require 'win32/daemon'
include Win32
require 'smart_proxy'

begin
  class SmartDaemon < Daemon
   include ::Proxy::Log
   def service_init
      logger.info("Service is initializing")
    end

    def service_main(*args)
      logger.info("Service is running")
      # Start the foreman daemon
      Proxy::Launcher.new.launch

      # the daemon is about to exit.
      logger.info("Service is terminating")
    end

    # This event triggers when the service receives a signal to stop.
    #
    # NOTE: Older versions of this code used an explicit exit! call
    # to force the Ruby interpreter to exit. Don't do that. It is no
    # longer required and, in fact, may cause issues.
    #
    def service_stop
      logger.info("Received stop signal")
    end

    # This event triggers when the service receives a signal to pause.
    #
    def service_pause
      logger.info("Received pause signal")
    end

    # This event triggers when the service receives a signal to resume
    # from a paused state.
    #
    def service_resume
      logger.info("Received resume signal")
    end
  end

  # Create an instance of the Daemon and put it into a loop. I borrowed the
  # method name 'mainloop' from Tk, btw.
  #
  SmartDaemon.mainloop
rescue Exception => e
  logger.error("Daemon failure: #{e}  #{e.backtrace}")
  raise
end

#2 Updated by Benjamin Papillon over 3 years ago

  • Related to Support #10098: Does anyone have an updated procedure to install smart proxy on a Windows Server 2008 R2 OS? added

#3 Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/smart-proxy/pull/285 added
  • Pull request deleted ()

#4 Updated by Dmitri Dolguikh over 3 years ago

  • Is duplicate of Bug #8793: Smart-proxy does not run as a service on Windows added

#5 Updated by Dmitri Dolguikh over 3 years ago

  • Is duplicate of deleted (Bug #8793: Smart-proxy does not run as a service on Windows)

#6 Updated by The Foreman Bot about 3 years ago

  • Assignee set to Dmitri Dolguikh

#7 Updated by Dominic Cleal about 3 years ago

  • Category set to Core
  • Legacy Backlogs Release (now unused) set to 104

#8 Updated by Dominic Cleal about 3 years ago

  • Related to Feature #12006: RFE: Be more specific about smart-proxy installation in windows added

#9 Updated by Anonymous about 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#10 Updated by Zak Herner about 3 years ago

I'm unable to get this to work. I've tried the steps above with gemfile.in and installing bundler_ext without any luck. I've tried a lot of things, ruby 1.9.3, 2.1.7 and 2.2.3 along with smart-proxy 1.7, 1.9, 1.10 and develop and no combination worked with smart-proxy-win-service.

From the win-service.log that gets created it has the following:
I, [2015-12-23T14:18:27.130041 #6992] INFO -- : Service is initializing
E, [2015-12-23T14:18:30.145679 #6992] ERROR -- : Daemon failure: Service_Main thread exited abnormally D:/foreman/Ruby22/lib/ruby/gems/2.2.0/gems/win32-service-0.8.7/lib/win32/daemon.rb:282:in `mainloop'
D:/foreman/Ruby22/lib/ruby/gems/2.2.0/gems/win32-service-0.8.7/lib/win32/daemon.rb:217:in `mainloop'
./bin/smart-proxy-win-service:39:in `<main>'

smart-proxy-win-service from the command line does not work but regular smart-proxy does work for me. I think it would be ideal to use smart-proxy-win-service but the option that worked for me was to use nssm.

#11 Updated by Dmitri Dolguikh about 3 years ago

The fix has been merged, bundler_ext and the workaround mentioned above isn't needed. Please follow installation docs for Windows (can be found here: http://theforeman.org/manuals/1.10/index.html) and see if it works for you.

#12 Updated by Zak Herner about 3 years ago

Dmitri Dolguikh wrote:

The fix has been merged, bundler_ext and the workaround mentioned above isn't needed. Please follow installation docs for Windows (can be found here: http://theforeman.org/manuals/1.10/index.html) and see if it works for you.

I was using the above doc to do the install and didn't have any luck. I'm installing on a new Win2K12 server, I also have the same issue on my Win7 workstation.

#13 Updated by James Camping about 3 years ago

Zak Herner wrote:

Dmitri Dolguikh wrote:

The fix has been merged, bundler_ext and the workaround mentioned above isn't needed. Please follow installation docs for Windows (can be found here: http://theforeman.org/manuals/1.10/index.html) and see if it works for you.

I was using the above doc to do the install and didn't have any luck. I'm installing on a new Win2K12 server, I also have the same issue on my Win7 workstation.

Try running "ruby bin\smart-proxy-win-service" In my case I had to change line 12 to specify a log file as an absolute path. After that the ruby service worked without issue.

#14 Updated by Dominic Cleal about 3 years ago

  • Legacy Backlogs Release (now unused) changed from 104 to 71

Non-trivial to backport, bumping to 1.11.0.

Also available in: Atom PDF