The installation documentation for CA Automic Workload Automation or CA Automic Service Manager does not provide a example how to set up the Service Manager autostart with systemd. To get this working cost me a lot of time and i like to share the problems and solutions with the community to help others setting up.
The following script ist tested with version 12.2 of the CA Automic Service Manager on a Suse Linux Enterprise Server 12 Service Pack 3 but will work also on other linux systems using systemd.
The most important fact about systemd is, that it will ignore any profile, bashrc and envfile for the user you supply for the deamon to run. Paying attention to this fact you need to declare all variables to the Service Manager process which are needed by the child processes started via the Service Manager. For communication (cp) and work processes (pwp, wp) you need to provide the oracle variables like TNS_ADMIN, ORACLE_HOME and the path to oracle libraries at LD_LIBRARY_PATH. If you are using the CA Private Key Infrastructure the variables CALIB, CABIN annd CASHCOMP need to be provided.
Important: Don't set the CA Service Manager bin directory or other Automion Engine directories in the LD_LIBRARY_PATH. This can cause serious problems with Zero Downtime Upgrade (ZDU) as Carsten_Schmitz mentioned in his disccussion PSA: $LD_LIBRARY_PATH (again), now with bonus ZDU troubles. A possible solution is to work with the unit file section WorkingDirectory set to the bin directory of CA Automic Service Manager.
# Systemd unit file for Automic Service Manager
Description=Automic Service Manager
ExecStart=/opt/uc4/smgr/bin/ucybsmgr -i/opt/uc4/smgr/bin/ucybsmgr.ini UC4D
ExecStop=/bin/kill -15 $MAINPID
If you like to have a central place to put all your enviromental variables on there is another elegant way to provide these to the CA Automic Service Manager process via the unit file. If you have declared all variables to the user you can use the ExecStartPre section to generate a environmental file.
ExecStartPre=/bin/bash --login -c '/usr/bin/env > /opt/uc4/env'
The hyphen before the environment file ignoring any error if the file does not exists or could not be read. You can prevent also a lot of odd errors if you work with absolute paths everywhere at the unit file. Also keep in mind, variable expansion does not work for Environment sections.
This document was written with help of the information of Carsten_Schmitz at discussion Besonderheiten bei Installation der Automation Engine auf Linux mit systemd / init.d
If you have additional information feel free to comment or write me message.