Windows Service Setup
-
Good Morning Everyone,
I'm working on getting a Windows 7 machine setup to use the YAJSW software to create a windows service for the Mango applilcation.
Setup is as follows:
Win 7
Mango running without issue via ma-start.
YAJSW serviceInstall executes succesfully.
Running runConsole will succesfully start Mango and the service tray manager.
When trying to start the service via the Windows Service Manager, I get a 1503 Service cannot start error.Almighty google suggests it could be a permissions or path problem, but from the steps I've taken so far it seems I may be chasing my tail.
Anyone have experience in getting a Windows service setup?
-
Hi Brad,
Do you get more information from attempting to run the service from the command prompt?
net start Mango
Assuming the name for your service in the wrapper.conf for YAJSW is 'Mango'
-
Running as the current user generates this:
System error 5 has occured.
Access is denied.Running in an Administrator console generates this:
System Error 2 has occurred.
The system cannot find the file specified.The service is running as Local System which has full rights on the folder. Looks like I have a path issue.
Thanks for the suggestion Phil. Back to the almighty google to see what I can find with the new info.
-
Changed the following
wrapper.java.command = java
to
wrapper.java.command = %JAVA_HOME%\\bin\\java
And now I am receiving
The service is not responding to the control function.
-
When I did this on one of my machines, I used the wrapper.java.command as java, but my jdk's bin directory is in my environment variable "PATH"
-
I've got it working now.
I have to download the latest version 12.06 and I copied their default config and made the appropriate mods based on the original config.
Here is the config:
# WARNING - Do not modify any of the properties when an application # using this configuration file has been installed as a service or daemon. # Please uninstall the service before modifying this file. The # service must then be reinstalled. #******************************************************************** # Java Executable Properties #******************************************************************** # Java Application wrapper.java.command=java # or define conditions for YAJSW searching for a JVM # currently only valid for windows #wrapper.java.command.minVersion=1.5 #wrapper.java.command.maxVersion=1.6 #wrapper.java.command.jreOnly=true #wrapper.java.command.jdkOnly=true #wrapper.java.command.preferJre=true #wrapper.java.command.preferJdk=true #wrapper.java.command.javaw=true # copy java.exe to <tmp>/java_<customProcName>_nnnn.exe #wrapper.java.customProcName= #******************************************************************** # working directory #******************************************************************** wrapper.working.dir=C:\\Mango\\bin\\ # Java Main class. # YAJSW: default is "org.rzo.yajsw.app.WrapperJVMMain" # DO NOT SET THIS PROPERTY UNLESS YOU HAVE YOUR OWN IMPLEMENTATION # wrapper.java.mainclass= #******************************************************************** # tmp folder # yajsw creates temporary files named in_.. out_.. err_.. jna.. # per default these are placed in jna.tmpdir. # jna.tmpdir is set in setenv batch file to <yajsw>/tmp #******************************************************************** wrapper.tmp.path = ${jna_tmpdir} #******************************************************************** # Application main class or native executable # One of the following properties MUST be defined #******************************************************************** # Java Application main class wrapper.java.app.mainclass=com.serotonin.m2m2.Main # or jar file #wrapper.java.app.jar= # or groovy script file #wrapper.groovy= #or a native executable #wrapper.image= #******************************************************************** # Application process cpu priority and affinity #******************************************************************** # Process priority: LOW, BELOW_NORMAL, NORMAL, ABOVE_NORMAL, HIGH #wrapper.priority # CPU affinity of the process. this is a bit-array representing the cpus #wrapper.affinity= #******************************************************************** # Application Account # Equivalent to Posix sudo or windows runas # Note Posix: # <group>\<user> (note: use \\ in configuration file). # If no group is configured default group of the user is used #******************************************************************** #wrapper.app.account= #wrapper.app.password= #******************************************************************** # Java/Groovy Application Properties #******************************************************************** # Java Classpath (include wrapper.jar) Add class path elements as # needed starting from 1 # YAJSW: all libs required by YAJSW are in the manifest of the wrapper.jar -> only classpath of your application is required wrapper.java.classpath.1 = C:\\Mango\\overrides\\classes wrapper.java.classpath.2 = C:\\Mango\\classes wrapper.java.classpath.3 = C:\\Mango\\overrides\\properties wrapper.java.classpath.4 = C:\\Mango\\overrides\\lib\\*.jar wrapper.java.classpath.5 = C:\\Mango\\lib\\*.jar # Java Library Path # YAJSW: required dll are encapsulated in jar files -> only library path of your application required # wrapper.java.library.path.1=../lib # Java Additional Parameters wrapper.java.additional.1 = -server wrapper.java.additional.2 = -Dma.home=C:\\Mango # Initial Java Heap Size (in MB) # alternative for wrapper.java.additional.<n>=-Xms #wrapper.java.initmemory=3 # % of total RAM #wrapper.java.initmemory.relative=10 # Maximum Java Heap Size (in MB) # alternative for wrapper.java.additional.<n>=-Xmx #wrapper.java.maxmemory=64 # % of total RAM #wrapper.java.maxmemory.relative=30 # JSW requires that main class is set as app.parameter property # YAJSW: to specify the main class please use wrapper.java.app.mainclass= #******************************************************************** # Application environment properties. #******************************************************************** # Adds an environment to the application #wrapper.app.env.<key>=<value> #******************************************************************** # Wrapper Logging Properties #******************************************************************** # Format of output for the console. (See docs for formats) # wrapper.console.format=PM # Log Level for console output. (See docs for log levels) wrapper.console.loglevel=INFO # Log file to use for wrapper output logging. wrapper.logfile=${wrapper_home}/log/wrapper.log # Format of output for the log file. (See docs for formats) #wrapper.logfile.format=LPTM # Log Level for log file output. (See docs for log levels) #wrapper.logfile.loglevel=INFO # Maximum size that the log file will be allowed to grow to before # the log is rolled. Size is specified in bytes. The default value # of 0, disables log rolling by size. May abbreviate with the 'k' (kB) or # 'm' (mB) suffix. For example: 10m = 10 megabytes. # If wrapper.logfile does not contain the string ROLLNUM it will be automatically added as suffix of the file name wrapper.logfile.maxsize=10m # Maximum number of rolled log files which will be allowed before old # files are deleted. The default value of 0 implies no limit. wrapper.logfile.maxfiles=10 # Controls the roll mode of the log file # possible values: DATE, WRAPPER, JVM # If DATE is set wrapper.logfile should contain the string YYYYMMDD # If DATE is set and wrapper.logfile.maxsize is set the log file will be rolled by size and date # If DATE is set and wrapper.logfile.maxfiles older files rolled by size or date are deleted #wrapper.logfile.rollmode=DATE #******************************************************************** # Application Console Properties #******************************************************************** # Indicate if console of the application is visible. #wrapper.console.visible=false # Title to use when running as a console wrapper.console.title=com.serotonin.m2m2.Main #******************************************************************** # Wrapper Windows Service and Posix Daemon Properties #******************************************************************** # Name of the service wrapper.ntservice.name=Mango # Display name of the service wrapper.ntservice.displayname=Mango # Description of the service wrapper.ntservice.description=Mango Automation # Service dependencies. Add dependencies as needed starting from 1 # wrapper.ntservice.dependency.1= # Mode in which the service is installed. AUTO_START or DEMAND_START # wrapper.ntservice.starttype=AUTO_START # Allow the service to interact with the desktop. # wrapper.ntservice.interactive=false # wrapper service user. only for windows. on *nix system this is root. # see also wrapper.app.account #wrapper.ntservice.account= #wrapper.ntservice.password= #******************************************************************** # Wrapper Posix Daemon Properties #******************************************************************** # Directory in which to create and execute daemon init scripts. Default: /etc/init.d #wrapper.daemon.dir = # Directory where to store the wrapper pid file. Default: /var/run #wrapper.daemon.pid.dir = # Directory in which to create K... and S... links. # Default: <wrapper.daemon.dir>/rcX.d # For Ubuntu set to /etc/rcX.d # The following grooy script should set it correctly for most distros wrapper.daemon.run_level_dir=${if (new File('/etc/rc0.d').exists()) return '/etc/rcX.d' else return '/etc/init.d/rcX.d'} # Setting the runlevels and priorities for automatic startup and stop of the daemon. # Similar syntax as the update_rc.d command # Default: equivalent to default of update_rc.d #wrapper.daemon.update_rc = start 20 2 3 4 . start 30 5 . stop 80 0 1 6 #******************************************************************** # Wrapper System Tray Properties #******************************************************************** # enable system tray wrapper.tray = true # TCP/IP port. If none is defined multicast discovery is used to find the port # Set the port in case multicast is not possible. wrapper.tray.port = 15002 # icon file to use, per default a console icon is used #wrapper.tray.icon= #******************************************************************** # Exit Code Properties # Restart on non zero exit code #******************************************************************** wrapper.on_exit.0=SHUTDOWN wrapper.on_exit.default=RESTART #******************************************************************** # Trigger actions on console output #******************************************************************** # On Exception show message in system tray wrapper.filter.trigger.0=Exception wrapper.filter.script.0=scripts/trayMessage.gv wrapper.filter.script.0.args=Exception #******************************************************************** # Wrapper JMX # # connect using for example jconsole per remote access using the url # # service:jmx:rmi:///jndi/rmi://localhost:1099/server # # eventl. change port and server name #******************************************************************** # Enable wrapper JMX #wrapper.jmx = true # JMX RMI port. default is 1099 #wrapper.jmx.rmi.port = # JMX RMI credentials # mandatory if accessing from remote server #wrapper.jmx.rmi.user = #wrapper.jmx.rmi.password = #******************************************************************** # Wrapper timeouts #******************************************************************** # Number of seconds to allow between the time that the Wrapper starts the application # and the application logon to the wrapper. # Default: 30 seconds #wrapper.startup.timeout = # Number of seconds to allow between the time that the Wrapper asks the application to shutdown and the time that the JVM shuts down. # Default: 30 seconds #wrapper.shutdown.timeout = # Number of seconds the wrapper waits for a ping message from the java application. # If no heart beat is received within a timeout the wrapper assumes that the application # is non responsive and will restart it. # Default: 30 seconds #wrapper.ping.timeout = #******************************************************************** # genConfig: further Properties generated by genConfig #******************************************************************** placeHolderSoGenPropsComeHere=
After running the installService.bat I had to edit the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Mango\ImagePath registry key from
java.exe -classpath C:\Mango\yajsw\wrapper.jar -Xrs -Dwrapper.service=true -Dwrapper.working.dir=C:\Mango\bin -Djna_tmpdir=C:\Mango\yajsw\bat\/../tmp -Dwrapper_home=C:\Mango\yajsw\bat\/.. -Dwrapper.config=C:\Mango\yajsw\conf\wrapper.conf -Dwrapper.additional.1x=-Xrs -Djna_tmpdir=C:\Mango\yajsw\bat\..\tmp org.rzo.yajsw.boot.WrapperServiceBooter
to
%JAVA_HOME%\bin\java.exe -classpath C:\Mango\yajsw\wrapper.jar -Xrs -Dwrapper.service=true -Dwrapper.working.dir=C:\Mango\bin -Djna_tmpdir=C:\Mango\yajsw\bat\/../tmp -Dwrapper_home=C:\Mango\yajsw\bat\/.. -Dwrapper.config=C:\Mango\yajsw\conf\wrapper.conf -Dwrapper.additional.1x=-Xrs -Djna_tmpdir=C:\Mango\yajsw\bat\..\tmp org.rzo.yajsw.boot.WrapperServiceBooter
Even with the PATH variable modified, i had to point it to the full path to get it to work.
For whatever reason it would not work for me with version 11.11.
Thanks for the help getting pointed in the right direction.
-
Nice! Thanks for sharing what resolved it for you!