Tuesday, 24 June 2014

Adding WAS as a Unix service

This came up in a conversation during a WAS 8.5.5 enablement session today.

It is possible to register and run a WAS server as a service on Linux.

This is how: -

$ /opt/IBM/WebSphere/AppServer/bin/wasservice.sh

CWSFU0010I: Usage: wasservice [options]
options:
[-start] <service name>
-add <service name>
-serverName <server name>
-profilePath <service profile directory>
[-wasHome <install root>]
[-userid <user id>]
[-startArgs <additional startServer parameters>]
[-stopArgs <additional stopServer parameters>]
-remove <service name>
-stop <service name>
-status <service name>


$ /opt/IBM/WebSphere/AppServer/bin/wasservice.sh -add foobar -serverName dmgr -profilePath /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/

Interestingly, the service name foobar gets "renamed" to foobar_was.init as evidenced here: -

$ls -altrc /etc/init.d/

-rwxr-xr-x   1 root root  1938 Jun 23 16:51 irqbalance
-rwxr-xr-x   1 root root  2571 Jun 23 16:51 mdmonitor
-rwxr-xr-x   1 root root  9980 Jun 24 13:30 jexec
drwxr-xr-x.  2 root root  4096 Jun 24 15:20 .
-rwx--x--x   1 root root  3335 Jun 24 15:20 foobar_was.init


and: -

$ chkconfig --list | grep -i foobar

foobar_was.init 0:off 1:off 2:on 3:on 4:on 5:on 6:off

I can now manage the server using standard Linux commands e.g.

$ service foobar_was.init start

Starting WebSphere Application Server - dmgr ...
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/startServer.log
ADMU0128I: Starting tool with the Dmgr01 profile
ADMU3100I: Reading configuration for server: dmgr
ADMU3200I: Server launched. Waiting for initialization status.
ADMU3000I: Server dmgr open for e-business; process id is 54588

$ service foobar_was.init status

WebSphere Application Server - dmgr is running.

$ service foobar_was.init stop

Stopping WebSphere Application Server - dmgr ...
ADMU0116I: Tool information is being logged in file
           /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/logs/dmgr/stopServer.log
ADMU0128I: Starting tool with the Dmgr01 profile
ADMU3100I: Reading configuration for server: dmgr
Realm/Cell Name: <default>
Username: wasadmin
Password:       
 ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server dmgr stop completed.

 
*UPDATE*
 
One thing that I realised after the event was that I'd neglected to specify the -userid parameter on the wasservice command, meaning that, when I started the Deployment Manager, it automatically started as root, rather than the required wasadmin.

This led to some problems when I tried to access the admin. console, where certain elements were completely blanked out, and I saw: -

...
[6/24/14 19:42:06:622 BST] 0000011d WorkSpaceMast E WKSP0012E: Exception while extracting cells/bpm85Cell/nodes/bpm85Node1/servers/dmgr/server.xml from ConfigRepository--com.ibm.websphere.management.exception.DocumentIOException: Unable to create temp file for document: cells/bpm85Cell/nodes/bpm85Node1/servers/dmgr/server.xml
[6/24/14 19:42:06:623 BST] 0000011d WorkSpaceMast E Unable to create temp file for document: cells/bpm85Cell/nodes/bpm85Node1/servers/dmgr/server.xml
[6/24/14 19:42:06:627 BST] 0000011d FileDocument E ADMR0104E: The system is unable to read document cells/bpm85Cell/nodes/bpm85Node1/servers/dmgr/server.xml: java.io.IOException: Permission denied
...

in the logs.

I validated this by inspecting the generated script - foobar_was.init - which contained: -

...
# *** THE FOLLOWING BLOCK IS PROGRAMMATICALLY MAINTAINED. ***
# *** PLEASE ALTER ONLY VIA THE WASSERVICE TOOL. ***
# START BLOCK
SERVERNAME="dmgr"
PROFILEPATH="/opt/IBM/WebSphere/AppServer/profiles/Dmgr01"
WASHOME="/opt/IBM/WebSphere/AppServer"
STARTARGS=""
STOPARGS=""
SERVICENAME="foobar_was.init"
RUNASUSER=
# END BLOCK
...

I fixed this by removing the service / script: -

$ /opt/IBM/WebSphere/AppServer/bin/wasservice.sh -remove foobar

and then recreated it as follows: -

$ /opt/IBM/WebSphere/AppServer/bin/wasservice.sh -add foobar -serverName dmgr -profilePath /opt/IBM/WebSphere/AppServer/profiles/Dmgr01/ -userid wasadmin

which changed the foobar_was.init script: -

...
# *** THE FOLLOWING BLOCK IS PROGRAMMATICALLY MAINTAINED. ***
# *** PLEASE ALTER ONLY VIA THE WASSERVICE TOOL. ***
# START BLOCK
SERVERNAME="dmgr"
PROFILEPATH="/opt/IBM/WebSphere/AppServer/profiles/Dmgr01"
WASHOME="/opt/IBM/WebSphere/AppServer"
STARTARGS=""
STOPARGS=""
SERVICENAME="foobar_was.init"
RUNASUSER="wasadmin"
# END BLOCK
...
 
which now works as expected.

No comments:

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...