B4J Question Procrun to manage B4J Server application as Windows Service

b4auser1

Well-Known Member
Licensed User
Longtime User
B4X:
http://commons.apache.org/proper/commons-daemon/procrun.html
prunsrv //IS//TestService --DisplayName="Test Service" \
--Install=prunsrv.exe --Jvm=auto--StartMode=jvm --StopMode=jvm \
--StartClass=org.apache.SomeStartClass--StartParams=arg1;arg2;arg3 \
--StopClass=org.apache.SomeStopClass--StopParams=arg1#arg2

What Java Class names from B4J application can be used for StartClass and StopClass parameters ?
 

b4auser1

Well-Known Member
Licensed User
Longtime User
Erel, thank you.
I want to stop application using StopMessageLoop or ExitApplication, which will be called from the StopClass.
If I don't use StopClass, then procrun will kill the application as far as I understand.
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
Erel,
Thank you.
Ok, I see. I created Handler class to call StopMessageLoop from it. I trigger the Handler using curl. Such a solution works for me.
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
Could you give more details why ExitApplication is more preferrable than StopMessageLoop to stop the server.
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
I have only one MessageLoop
B4X:
Sub AppStart (Args() As String)

    m_clsMain_AppContainer.Initialize

    m_clsMain_AppContainer.Start
    StartMessageLoop
    m_clsMain_AppContainer.Finish
   
End Sub
and use this handler
B4X:
Public Sub Handle(req As ServletRequest, resp As ServletResponse)
    resp.ContentType = "text/html"
        resp.Write("Server stopping ...")
        StopMessageLoop
End Sub
to stop the server and send the web page to a client with the message "Server stopping ..."
and it works like a charm.
If I replace StopMessageLoop with ExitApplication then server stops, but the webpage "Server stopping ..." is not displayed to the client.
 
Upvote 0
Top