1. Web Service Configuration

There are 2 configuration parameters for the web service in the file generic.xml in the config directory, ws_port and sqlite_db. ws_port defines the port on which the service will run and sqlite_db defines the location of the SQLite database file where job related data is stored. By default a temporary file location is used by specifying TMP. If :memory: is used an in-memory SQLite database will be used, however the data in this location will not be stored after the webservice stops and is incompatible with functionality such as time profiling, for this reason an on-disk location is recommended.

   <sqlitedb>
        <sqlitedb_dir>TMP</sqlitedb_dir>
   </sqlitedb>

  <webservice>
   <ws_port>8080</ws_port> 
  </webservice>

The webservice can be configured under the GUI under the new Jobs option.

Figure 10.1. Jobs Option

Jobs Option


Under Options you can Enable/Disable the Jobs interface. If disabled no Job related information will be stored in the SQLite database. When enabled you have the option to set the port that the Web Service will listen on and to start and stop the Web Service.

Figure 10.2. Jobs and Web Service Configuration

Jobs and Web Service Configuration

When running the Status button will show the Web Service environment.

Figure 10.3. Web Service Status

Web Service Status

The same commands can also be run from the CLI to enable or disable Jobs and to start/stop the Web Service.

hammerdb>jobs disable 0
Enabling jobs repository, restart HammerDB to take effect

hammerdb>jobs disable 1
Disabling jobs repository, restart HammerDB to take effect

hammerdb>wsport
Web Service Port set to 8080

hammerdb>wsstart
HammerDB Web Service v4.8
Copyright (C) 2003-2023 Steve Shaw
Type "help" for a list of commands

hammerdb>Starting HammerDB Web Service on port 8080

hammerdb>wsstatus
Web Service running: Service Environment

BASE_URL = http://localhost:8080
DOCUMENT_ROOT = {C:/Program Files/HammerDB-4.8}
HTTP_ACCEPT_ENCODING = gzip,deflate,compress
HTTP_HOST = localhost:8080
HTTP_USER_AGENT = {Mozilla/5.0 (Windows; U; Windows NT 10.0) http/2.9.5 Tcl/8.6.12}
PATH_HEAD = env
PATH_INFO = /env
PATH_TAIL = {}
QUERY_STRING = {}
REMOTE_ADDR = ::1
REMOTE_PORT = 63830
REQUEST_METHOD = GET
REQUEST_URI = /env
SAME_ORIGIN = 0
SCRIPT_FILENAME = {C:/Program Files/HammerDB-4.8/wait}
SCRIPT_NAME = {}
SELF_URL = http://localhost:8080/env
WAPP_MODE = server
[pwd] = {C:/Program Files/HammerDB-4.8}

hammerdb>wsstop
Stopping HammerDB Web Service on port 8080

You can also start and stop the Web Service directly. With no arguments or the argument of wait the Web Service will wait in listening mode.

:\Program Files\HammerDB-4.8>hammerdbws
HammerDB Web Service v4.8
Copyright (C) 2003-2023 Steve Shaw
Type "help" for a list of commands
Starting HammerDB Web Service on port 8080

With the argument of nowait the Web Service will return a prompt. This allows you to manually interact with the Web Service API and return Job related html to the prompt.

C:\Program Files\HammerDB-4.8>hammerdbws nowait
HammerDB Web Service v4.8
Copyright (C) 2003-2023 Steve Shaw
Type "help" for a list of commands
Starting HammerDB Web Service on port 8080

hammerws>help
HammerDB Web Service
Help:
GET jobs: Show the job ids, configuration, output, status, results and timings of jobs created by buildschema and vurun. Job output is equivalent to the output viewed in the graphical interface or command line.
get http://localhost:8080/jobs
get http://localhost:8080/jobs?jobid=TEXT
get http://localhost:8080/jobs?jobid=TEXT&bm
get http://localhost:8080/jobs?jobid=TEXT&db
get http://localhost:8080/jobs?jobid=TEXT&delete
get http://localhost:8080/jobs?jobid=TEXT&dict
get http://localhost:8080/jobs?jobid=TEXT&index
get http://localhost:8080/jobs?jobid=TEXT&result
get http://localhost:8080/jobs?jobid=TEXT&resultdata
get http://localhost:8080/jobs?jobid=TEXT&status
get http://localhost:8080/jobs?jobid=TEXT&tcount
get http://localhost:8080/jobs?jobid=TEXT&tcountdata
get http://localhost:8080/jobs?jobid=TEXT&timestamp
get http://localhost:8080/jobs?jobid=TEXT&timing
get http://localhost:8080/jobs?jobid=TEXT&timingdata
get http://localhost:8080/jobs?jobid=TEXT&timing&vuid=INTEGER
get http://localhost:8080/jobs?jobid=TEXT&vu=INTEGER

hammerws>jobs
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="http://localhost:8080/style.css" rel="stylesheet">
<title>HammerDB Results</title>
</head>
<body>
<p><img src='http://localhost:8080/logo.png' width='347' height='60'></p><h3 class="title">Job Index:</h3><div class='hammerdb' data-title='Jobs'><div><ol style='column-width: 20ex;'>
<br><table>