Creating a Windows service for your Studio WebLogic domain

After you deploy Studio into the WebLogic domain, you can then create a Windows service for the domain.

To create and configure a Windows service for Studio:

  1. In <MiddlewareHomeDirectory>\user_projects\domains\<StudioDomain>\servers\AdminServer, create the following files:
    • install_studio_service.cmd
    • uninstall_studio_service.cmd
  2. Set the content of install_studio_service.cmd as follows:
    echo off
    SETLOCAL
    set DOMAIN_NAME=<StudioDomain>
    set SERVER_NAME=AdminServer
    set USERDOMAIN_HOME=<MiddlewareHomeDirectory>\user_projects\domains\%DOMAIN_NAME%
    set WL_HOME=<MiddlewareHomeDirectory>
    set WLS_USER=<StudioDomainUserName>
    set WLS_PW=<StudioDomainPassword>
    call "%WL_HOME%\server\bin\installSvc-studio.cmd"
    ENDLOCAL 

    Where:

    Value Definition
    <StudioDomain> The name of your Studio WebLogic domain.
    <MiddlewareHomeDirectory> The full path to the Middleware Home directory.
    <StudioDomainUserName> The user name for the Studio domain.
    <StudioDomainPassword> The password for the Studio domain.

    The WLS_USER and WLS_PW parameters are used to provide the WebLogic credentials. Instead of providing these parameters, you can also use boot.properties.

    For information on using boot.properties to provide the credentials, see http://docs.oracle.com/cd/E23943_01/web.1111/e13708/winservice.htm#i1188258.

  3. Set the content of uninstall_studio_service.cmd as follows:
    echo off
    SETLOCAL
    set DOMAIN_NAME=<StudioDomain>
    set SERVER_NAME=AdminServer
    set WL_HOME=<MiddlewareHomeDirectory>
    "%WL_HOME%\server\bin\beasvc" -remove -svcname:"beasvc %DOMAIN_NAME%_%SERVER_NAME%"
    ENDLOCAL

    Where:

    Value Definition
    <StudioDomain> The name of your Studio WebLogic domain.
    <MiddlewareHomeDirectory> The full path to the Middleware Home directory.
  4. Go to %WL_HOME%\server\bin.
  5. Make a copy of installSvc.cmd, and name it installSvc-studio.cmd.
  6. Go to %WL_HOME%\common\bin.
  7. Make a copy of commEnv.cmd, and name it commEnv-studio.cmd.
  8. Modify commEnv-studio.cmd as follows:
    1. Modify the :sun and :sun_prod_mode sections of the script to set the memory parameters:
      set JAVA_VM=-server
      set MEM_ARGS=-Xms1G -Xmx1G -Xss1m -XX:MaxPermSize=512m -XX:+UseSpinning
      goto continue

      Set -Xmx to at least 1G.

      Set -Xms to match -Xmx.

      Increase -XX:MaxPermSize to 512m.

      Set –Xss to 1m.

      You may have to increase -Xmx/-Xms later on depending on your application's memory requirements.

    2. Add the following JAVA_OPTIONS line to the top of commEnv-studio.cmd, after the comments section:
      set
      JAVA_OPTIONS=-Dweblogic.Stdout="%USERDOMAIN_HOME%\studio_service_stdout.txt"
      -Dweblogic.Stderr="%USERDOMAIN_HOME%\studio_service_stderr.txt"
      -Dfile.encoding=UTF8 -DUseSunHttpHandler=true
      -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
      -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
      -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

      While the block above includes line breaks for readability, make sure to add this as a single line with the parameters separated by a space.

      -Dweblogic.Stdout and -Dweblogic.Stderr redirect standard out/err for the Windows service to log files residing under %USERDOMAIN_HOME%.

      Note that the value for %USERDOMAIN_HOME% is already set in install_studio_service.cmd.

  9. Modify installSvc-studio.cmd to change the call statement at the top of the file to reference commEnv-studio.cmd:
    call "%WL_HOME%\common\bin\commEnv-studio.cmd"
  10. To install the service, from a command prompt launched in Run As Administrator mode in Windows, run the install_studio_service.cmd script.

    This installs a new Window service called beasvc %DOMAIN_NAME%_%SERVER_NAME% (for example, beasvc endeca_studio_domain_AdminServer):

    Note that whenever you make changes to commEnv-studio.cmd or installSvc-studio.cmd, you must reinstall the Windows service:

    1. Run uninstall_studio_service.cmd.
    2. Run install_studio_service.cmd.
  11. Start the new Windows service.
    If successful, the service starts up, and information is written to %USERDOMAIN_HOME%\studio_service_stdout.txt showing a successful startup message after a short wait.
  12. Once you confirm that Studio works correctly when started using the Windows service, stop the Windows service.

    Confirm that the service can successfully stop and terminate the WebLogic domain.

For additional details on creating a Windows service for WebLogic, including information on enabling graceful shutdowns for the Windows service, see the WebLogic documentation (http://docs.oracle.com/cd/E23943_01/web.1111/e13708/winservice.htm).