Registry as a service (example)

NSSM

To easily create a service in windows we use NSSM (the Non-Sucking Service Manager)

Once this is downloaded or located in the provided source files you will need a command promt with administrative privileges.

Create a service

using NSSM we will create a serivce based of the registry executable.

Depending on the customer you will need to change some names (registry executable, service name, path, arguments)

nssm.exe install Trust1Connector-registry C:\<path-where-registry-is-located>\t1c-reg.exe [arguments]

In the above command we create a service named Trust1Connector-registry which will run the t1c-reg.exe as a service.

The above accepts a list of arguments. To set these you will need to add them just like you would add them for running the registry manually

Example

nssm.exe install Trust1Connector-registry C:\<path-where-registry-is-located>\t1c-reg.exe -f -p 51983

The registry accepts the following arguments;

USAGE:
    t1c-reg [FLAGS] [OPTIONS]

FLAGS:
    -d, --debug         Enables debug mode and additional debug logging
        --ds.reg        Enables the use of the Distribution service Registry (only in online mode) - ds.server_address
                        MUST be provided
        --enable.jwt    Enables the use of JWT validation middleware on the API server. No use cases can be performed
                        without sending a valid JWT from the consumer request. The JWT must be issued by the configured
                        DS.
    -f                  Enables the use for the file logger <logs/t1c-reg.log>
    -h, --help          Prints help information
    -V, --version       Prints version information

OPTIONS:
        --cors <cors>                        Provide a base64 encode, comma-separated list of cors origins to be
                                             provided on startup. When using a Distribution Service, the CORS is
                                             overwritten by the DS configuration.
        --ds.server_address <ds.t1t.io>      Activated ONLINE mode using given Distribution Service Host. If not given,
                                             the T1C-API runs in OFFLINE mode
        --env <prod>                         The environment running under. The value is passed through form the T1C-API
                                             initiating the registry
    -p, --reg.port <51883>                   Sets the Registry port
    -s, --reg.server_address <t1c.t1t.io>    Sets the Registry URI
    -U, --user.path <.>                      Set the user folder for pem/cert and log files

Starting the service

altough the service will automatically start upon startup of the system it will not start immediatley after installing the service with NSSM. If you wish to not reboot you can use NSSM to start the service yourself.

To do this you can use the following command;

nssm.exe start Trust1connector-registry

Service management

You can use NSSM further down the road to start/stop or restart the service yourself. These commands are similar to the start command you can find in this document. Information about the other features of NSSM you can check their documentation here

The most simple ones are start, stop, restart, remove

some examples;

# To start the service
nssm.exe start Trust1Connector-registry

# To stop the service
nssm.exe stop Trust1Connector-registry 

# To restart the serivce
nssm.exe restart Trust1Connector-registry

# To remove the service (first stop the service before removing it)
nssm.exe remove Trust1Connector-registry