Andrew_Benjamin_8791

Appworx V8 systemctl (System-D) script (Application Manager)

Discussion created by Andrew_Benjamin_8791 on Jan 31, 2017

After doing some testing with the V8 Appworx which has support for RHEL 5,6,7 but not Oracle Linux 7.  I found that everything appears to work correctly.  The only thing I uncovered is the agent might take a while to initially status to the master once the agent is started.  Otherwise, everything works from what I can tell.

Disclaimer: Appworx v8 is not supported on Oracle Linux 7 as per our discussions, the software has not been QA'd and it has not been fully approved for the operating system per their release documentation here:

https://docs.automic.com/tools/compatibility_checker?compatibility-mode=component&lifecycle_entity_id=1409731986339&version_id=1452593079908

As you might have noticed, Appworx does come with an init.d script but this does not work for RHEL7 or OL7 due to the new System-D startup which Red Hat has changed over to.  Therefore, there is a bit of a trick to get things working but once it is done, it will work with the Appworx agent to start with the server.

First you will need to create the unit script:

(This file will contain the parameters for how to call the startup and shutdown parameters of the agent.)

/etc/systemd/system
-rw-r--r--   1 root root  234 Jan 20 17:06 appworx.service

 

---------------------------

[Unit]                                          
Description=Appworx Agent     (Name of the service to appear in system-d)
After=splunk.service                  (What application the service should start up after)
DefaultDependencies=no           (Any specific dependencies, there is another flag you can set to make it dependent on a service)

[Service]                    (Service section for how to handle the system calls)                                    
Type=forking            (We will have to use "forking" as we don't want system-d to check after start, this exhibits init.d behavior.)
ExecStart=/home/appwrxd/initd/startaw
ExecStop=/home/appwrxd/initd/stopaw
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

---------------------------

Unit - Starting section for the unit definition
Description - Name of the service to appear in system-d
After - What application the service should start up after
DefaultDependencies - Any specific dependencies, there is another flag you can set to make it dependent on a service like networking or other services.
Service - Service section for how to handle the system calls
Type - We will have to use "forking" as we don't want system-d to check after start, this exhibits init.d behavior as we will have it call startup and shutdown scripts.
ExecStart - The script which should be called on startup
ExecStop - The script which should be called on shutdown
RemainAfterExit - This will allow the service to stay in the current state for System-D
Install - This is where we want the system-d script to go once it is registered with the system.

As you might have noticed above I am calling other scripts as part of the system-d unit so lets put them in place as well.

In "/home/appwrxd" ($APPWORX_HOME) create initd
drwxr-xr-x   2 root    root    4.0K Jan 20 17:07 initd

Then create the following script:
-rwxr-xr-x  1 root    root     274 Jan 20 17:07 startaw

--------------------

#!/bin/bash -

# Source function library.
. /etc/rc.d/init.d/functions

        touch /var/lock/subsys/appworx
        sleep 60
        su - appwrxd -c "startso all" 1>/home/appwrxd/init.d.out 2>&1
        su - appwrxd -c "startso watchworx" 1>/home/appwrxd/init.d.out 2>&1

--------------------

Also, create the following script:
-rwxr-xr-x  1 root    root     180 Jan 20 17:07 stopaw

----------------

#!/bin/bash -

# Source function library.
. /etc/rc.d/init.d/functions

        rm -f /var/lock/subsys/appworx
        su - appwrxd -c "stopso all" 1>/home/appwrxd/init.d.out 2>&1

----------------

Per the script shell definition "#!/bin/bash -" the "-" specific value for some reason was stated to me as a service script call, not really sure if that is needed but it seems to fix some issues which were hard to track down with system-D.

In your directory, you should now have:
-rwxr-xr-x  1 root    root     274 Jan 20 17:07 startaw
-rwxr-xr-x  1 root    root     180 Jan 20 17:07 stopaw

(You might need to "chmod 755" the files to get them to work!)  Also please ensure you have your paths correct for the startup and shutdown paramaters in both scripts and in the System-D unit, this caused issues for me while trying to get things working.

Once everything is in place you will need to do the following:

Enable the service in system-D:    systemctl enable appworx.service
Reload the System-D daemon:        systemctl daemon-reload
Start the new service:             systemctl start appworx.service
Status the new service:            systemctl status appworx.service

Since we have wait paramaters, it will take a bit on startup so I typically will use the following command:

#> watch "systemctl status appworx.service"

(Use CTRL+C to stop the watch command)

Troubleshooting:

- Use the systemctl status command to see if it starts, debug options will also be displayed with system-d if you have a script related issue.

- Check your path values, this one keeps throwing me off as we have many agents installed in our environment, it crucial to make sure your paths align in the scripts and the system-d service file.

- Always remember when using the "systemctl enable" or "systemctl disable" calls you will want to run the "systemctl daemon-reload" command so the startup/shutdown parameters can be adjusted on the system.  System-D will warn about this as well once a change has been done. 

Hopefully you can find this useful as we have 6+ systems already running on Oracle Linux 7 without any issues using this configuration.

 

 

Outcomes