Closed afraniosm closed 7 years ago
Hi @afraniosm, I'd go for adding the dummy parameter to Bootstrapper because it looks like the smallest modification. In case, could you please do that and open a Pull Request? I don't use Windows, so I can't test it by myself.
PR merged, thank you.
Ok, I've compiled and tested.
I've installed the service with:
restheart.exe install --DisplayName=RestHeart --Install=C:\restheart-3.1.0-SNAPSHOT\restheart.exe --Description="RestHeart HAL API for MongoDB Service" --Jvm=auto --StartMode=jvm --StopMode=jvm --StartClass=org.restheart.Bootstrapper --StopClass=org.restheart.Bootstrapper --StartParams=etc/restheart.yml --StartMethod=main --StopMethod=shutdown --StartPath=C:\restheart-3.1.0-SNAPSHOT --LogPath=C:\restheart-3.1.0-SNAPSHOT\log --Classpath=restheart.jar
where prunsrv.exe is renamed to restheart.exe, see procrun docs .
after restheart.exe start, in C:\restheart-3.1.0-SNAPSHOT\log:
type C:\restheart-3.1.0-SNAPSHOT\log\commons-daemon.2017-05-11.log
[2017-05-11 13:25:08] [info] [ 3988] Commons Daemon procrun (1.0.15.0 64-bit) started [2017-05-11 13:25:08] [info] [ 3988] Service restheart name RestHeart [2017-05-11 13:25:09] [info] [ 3988] Service 'restheart' installed [2017-05-11 13:25:09] [info] [ 3988] Commons Daemon procrun finished [2017-05-11 13:27:50] [info] [ 1780] Commons Daemon procrun (1.0.15.0 64-bit) started [2017-05-11 13:27:50] [info] [ 1780] Running 'restheart' Service... [2017-05-11 13:27:50] [info] [ 1832] Starting service... [2017-05-11 13:28:01] [info] [ 1832] Service started in 10321 ms.
type C:\restheart-3.1.0-SNAPSHOT\log\restheart.log
13:28:01.509 [main] [34mINFO [0;39m org.restheart.Bootstrapper - Starting [31;1mRESTHeart[m instance [31;1mdefault[m 13:28:01.512 [main] [34mINFO [0;39m org.restheart.Bootstrapper - version 3.1.0-SNAPSHOT 13:28:01.514 [main] [34mINFO [0;39m org.restheart.Bootstrapper - Logging to file C:\restheart-3.1.0-SNAPSHOT\log\restheart.log with level INFO 13:28:01.514 [main] [34mINFO [0;39m org.restheart.Bootstrapper - Stop logging to console 13:28:07.595 [main] [34mINFO [0;39m org.restheart.Bootstrapper - MongoDB connection pool initialized 13:28:07.595 [main] [34mINFO [0;39m org.restheart.Bootstrapper - MongoDB version 3.4.4 13:28:11.808 [main] [34mINFO [0;39m org.restheart.Bootstrapper - Token based authentication enabled with token TTL 15 minutes 13:28:11.922 [main] [34mINFO [0;39m org.restheart.Bootstrapper - HTTP listener bound at 0.0.0.0:80 13:28:11.925 [main] [34mINFO [0;39m org.restheart.Bootstrapper - Local cache for db and collection properties enabled with TTL 1000 msecs 13:28:11.925 [main] [34mINFO [0;39m org.restheart.Bootstrapper - Local cache for schema stores enabled with TTL 1000 msecs 13:28:13.250 [main] [34mINFO [0;39m org.restheart.Bootstrapper - URL / bound to MongoDB resource * 13:28:14.041 [main] [34mINFO [0;39m org.restheart.Bootstrapper - URL /browser bound to static resources C:\restheart-3.1.0-SNAPSHOT\halbrowser. Access Manager: true 13:28:14.071 [main] [34mINFO [0;39m org.restheart.Bootstrapper - URL /_logic/ping bound to application logic handler org.restheart.handlers.applicationlogic.PingHandler. Access manager: false 13:28:14.071 [main] [34mINFO [0;39m org.restheart.Bootstrapper - URL /_logic/roles bound to application logic handler org.restheart.handlers.applicationlogic.GetRoleHandler. Access manager: true 13:28:14.072 [main] [34mINFO [0;39m org.restheart.Bootstrapper - URL /_logic/ic bound to application logic handler org.restheart.handlers.applicationlogic.CacheInvalidator. Access manager: true 13:28:14.073 [main] [34mINFO [0;39m org.restheart.Bootstrapper - URL /_logic/csv bound to application logic handler org.restheart.handlers.applicationlogic.CsvLoaderHandler. Access manager: true 13:28:15.286 [main] [34mINFO [0;39m org.restheart.Bootstrapper - [32;1mRESTHeart started[m
Obs: I've defined restheart.log in etc/restheart.yml
I had to make minor modifications to install RestHeart as a service in Windows via Apache Procrun (used by Tomcat). The problem is that
org.restheart.Bootstrapper.shutdown()
can't be used as--StopMethod
parameter for procrun as the documentation says:So to use procrun you may either:
add dummy parameter to Bootstrapper:
add start and stop parameters in
org.restheart.Bootstrapper.main()
, not sure exactly how. I think this is ugly.add Stop (optionally another Start) class like that (this is what I did):
I think procrun is the easiest/fastest way to install restheart as Windows service, but it needs just a little tweak to make it go smoothly. Now it's up to you the most suitable solution to integrate.