0

Windows サービスにしたい JRuby プログラムがあります。Ruby を使用したサービスの作成についていくつか見てきましたが、クライアント マシンに Ruby をインストールしたくありません。JRuby ではサポートされていないようです。

これを試すためにダミープログラムを作成しました:

path = "C:/tmp/my-svc.log"

if File.exists?(path)
    File.open(path,"a"){|f| f.write(" called again\n")}
else  
    File.open(path,"w"){|f| f.write(" called first time\n")}
end

while true do   
    sleep 5
    puts 'I am a service'
end

これは私がしました:

Z:\play>sc.exe create "larz service 2.1" binpath= "C:\jruby-1.6.7.2\bin\jruby -SZ:\play\my-win-svc.rb" start= auto

[SC] CreateService 成功

起動しようとすると、次のエラーが発生しました。

Z:\play>sc start "larz サービス 2.1"

[SC] StartService がエラー 193 で失敗しました。

Z:\play>sc query "larz サービス 2.1"

SERVICE_NAME: larz service 2.1`
TYPE               : 10  WIN32_OWN_PROCESS`
STATE              : 1  STOPPED
WIN32_EXIT_CODE    : 0  (0x0)
SERVICE_EXIT_CODE  : 0  (0x0)
CHECKPOINT         : 0x0
WAIT_HINT          : 0x0

initsrv.exe、powershell、CMD の実行、レジストリの編集などを使用して Windows サービスを作成するさまざまな方法について、Web 上で多くの投稿を見てきましたが、実際に何が起こっているのか、または呼び出す必要があるのか​​どうかはわかりません。いくつかの API。他のアプローチが、私が知ることができる特定の開始パラメーターを追加するようには見えません。さらに、/tmp 内のファイルに書き込むコードをテスト サービスの最初に追加しましたが、ファイルが書き込まれていないため、プログラムを開始しようとしても実際には実行されません。

ありがとう ..


わかりました、それで私は少し遠くに行きましたが、まだ当惑しています

Z:\play>sc config "larz service 2.2" obj= EEE\lgud password= "Ssssssss@"

[SC] ChangeServiceConfig 成功

Z:\play>sc start "larz サービス 2.2"

[SC] サービスの開始に失敗しました 1069:

ログオンに失敗したため、サービスが開始されませんでした。

config コマンドでエラーが発生したこともあるため、user/pw の正しい形式を入力したようです。

4

1 に答える 1

0

If you are positive that the password is correct, perhaps the user you have specified doesn't have the right privileges to run as a service. Try entering the account information on the Windows Services Application (services.msc) Log On tab, which will let you know if there is a problem with that user.

But beyond that, I don't see how you're going to get this going without Ruby installed. Your service's executable path is set to a .rb file -- what application do you expect Windows to launch to run that file, if not Ruby?

于 2013-03-12T03:37:47.497 に答える