1053 Error about win32-service

Discussion in 'Ruby' started by Kai Geng, Dec 12, 2007.

  1. Kai Geng

    Kai Geng Guest

    Hi
    I have installed the gem of win32-service-0.6.0-x86-mswin32-60.gem.But
    when I run my test code such as:

    require 'rubygems'
    require 'win32/service'
    include Win32

    s = Service.new
    s.create_service{ |srv|
    srv.service_name = "foo"
    srv.binary_path_name = "D:\\Ruby\\bin\\ruby "+File.expand_path($0)
    srv.display_name = "Test_service"
    }
    s.close

    Service.start("foo")

    I will get a 1053 ERROR. How can I rescue the error?

    Attachments:
    http://www.ruby-forum.com/attachment/1128/moz-screenshot.jpg

    --
    Posted via http://www.ruby-forum.com/.
    Kai Geng, Dec 12, 2007
    #1
    1. Advertising

  2. Kai Geng

    Jano Svitok Guest

    On Dec 12, 2007 4:51 AM, Kai Geng <> wrote:
    > Hi
    > I have installed the gem of win32-service-0.6.0-x86-mswin32-60.gem.But
    > when I run my test code such as:
    >
    > require 'rubygems'
    > require 'win32/service'
    > include Win32
    >
    > s = Service.new
    > s.create_service{ |srv|
    > srv.service_name = "foo"
    > srv.binary_path_name = "D:\\Ruby\\bin\\ruby "+File.expand_path($0)
    > srv.display_name = "Test_service"
    > }
    > s.close
    >
    > Service.start("foo")
    >
    > I will get a 1053 ERROR. How can I rescue the error?


    I suggest you google for "1053 ERROR win32-service ruby".

    You may start the service from the command line (net start foo) to see
    if you get an additional debug info.

    Then, try running your service in standalone mode (i.e. just run
    "D:\\Ruby\\bin\\ruby "+File.expand_path($0))

    The error you get might be dependant on OS version (XP/2K3/vista) and
    the user it runs under (default is SYSTEM).

    There are several constraints what you can and cannot do when running
    as service. Most notably, you won't have access to
    stdin/stdout/stderr,
    and to any substed/mapped/network disks. The PATH might be different as well.
    Jano Svitok, Dec 12, 2007
    #2
    1. Advertising

  3. Kai Geng

    Jano Svitok Guest

    On Dec 12, 2007 4:51 AM, Kai Geng <> wrote:
    > Hi
    > I have installed the gem of win32-service-0.6.0-x86-mswin32-60.gem.But
    > when I run my test code such as:
    >
    > require 'rubygems'
    > require 'win32/service'
    > include Win32
    >
    > s = Service.new
    > s.create_service{ |srv|
    > srv.service_name = "foo"
    > srv.binary_path_name = "D:\\Ruby\\bin\\ruby "+File.expand_path($0)
    > srv.display_name = "Test_service"
    > }
    > s.close
    >
    > Service.start("foo")
    >
    > I will get a 1053 ERROR. How can I rescue the error?


    After reading your other thread I see your problem now:

    Just make TWO scripts: one for registering the service and the other
    for the service itself.
    You don't need to register the service again when it's just being started.

    Or, you can merge them in one file, but distinguish among them using
    command line options.
    I mean, if you run my_service --register or my_service --unregister,
    then it will to the register/unregister stuff.
    Without option, it will run the Daemon stuff.

    Note that in order to start the notepad, you might need to allow the
    service interact with desktop. (Though
    I don't remember if this is valid for xp or for vista only. Have a
    look in the service's properties.)
    Jano Svitok, Dec 12, 2007
    #3
  4. Kai Geng

    Jano Svitok Guest

    On Dec 12, 2007 12:35 PM, Jano Svitok <> wrote:
    > Or, you can merge them in one file, but distinguish among them using
    > command line options.
    > I mean, if you run my_service --register or my_service --unregister,
    > then it will to the register/unregister stuff.
    > Without option, it will run the Daemon stuff.


    see mongrel_service how they do it.
    Jano Svitok, Dec 12, 2007
    #4
  5. Kai Geng

    Anthrax Guest

    Jano Svitok 写é“:
    > On Dec 12, 2007 12:35 PM, Jano Svitok <> wrote:
    >
    >> Or, you can merge them in one file, but distinguish among them using
    >> command line options.
    >> I mean, if you run my_service --register or my_service --unregister,
    >> then it will to the register/unregister stuff.
    >> Without option, it will run the Daemon stuff.
    >>

    >
    > see mongrel_service how they do it.
    >
    >
    >

    Thanks for Jano Svitok.I have rescued the problem with your help.
    Anthrax, Dec 12, 2007
    #5
  6. On Dec 11, 8:51 pm, Kai Geng <> wrote:
    > Hi
    > I have installed the gem of win32-service-0.6.0-x86-mswin32-60.gem.But
    > when I run my test code such as:
    >
    > require 'rubygems'
    > require 'win32/service'
    > include Win32
    >
    > s = Service.new
    > s.create_service{ |srv|
    > srv.service_name = "foo"
    > srv.binary_path_name = "D:\\Ruby\\bin\\ruby "+File.expand_path($0)
    > srv.display_name = "Test_service"}
    >
    > s.close
    >
    > Service.start("foo")


    One thing you'll want to be aware of is that there was an interface
    change in 0.6.0. Here's an example that uses most of the available
    options:

    # Create a new service
    Service.create('some_service', nil,
    :service_type => Service::WIN32_OWN_PROCESS,
    :description => 'A custom service I wrote just for fun'
    :start_type => Service::AUTO_START,
    :error_control => Service::ERROR_NORMAL,
    :binary_path_name => 'C:\path\to\some_service.exe',
    :load_order_group => 'Network',
    :dependencies => ['W32Time','Schedule']
    :service_start_name => 'SomeDomain\\User',
    :password => 'XXXXXXX',
    :display_name => 'This is some service',
    )

    Regards,

    Dan
    Daniel Berger, Dec 12, 2007
    #6
  7. Kai Geng

    Kai Geng Guest

    Daniel Berger wrote:
    >
    >
    > One thing you'll want to be aware of is that there was an interface
    > change in 0.6.0. Here's an example that uses most of the available
    > options:
    > ......
    > Regards,
    >
    > Dan


    Thanks for your help and your win32-service gem :)
    --
    Posted via http://www.ruby-forum.com/.
    Kai Geng, Dec 13, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?M2Ry?=
    Replies:
    2
    Views:
    10,918
    Steven Cheng[MSFT]
    Sep 7, 2004
  2. Kai Geng
    Replies:
    0
    Views:
    181
    Kai Geng
    Dec 12, 2007
  3. Rajiv Abraham
    Replies:
    3
    Views:
    287
    Rajiv Abraham
    Apr 16, 2010
  4. Ziv Tepman
    Replies:
    0
    Views:
    59
    Ziv Tepman
    Jan 21, 2014
  5. Ziv Tepman
    Replies:
    0
    Views:
    79
    Ziv Tepman
    Jan 21, 2014
Loading...

Share This Page