This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Problem creating a Linux 'service' to handle startup

I'm really enjoying running DPA on Linux, but the main thing I was missing was a 'service' that starts and stops the DPA service.

For this instance, I'm running DPA 2021.1.889 on Rocky Linux 8.4. Rocky behaves nearly identically to CentOS (which is very similar to Red Hat).

I created a new /etc/systemd/system/dpa.service file with the following contents:

[Unit]
Description=Database Performance Analyzer (DPA)
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=sh /var/opt/solarwinds/dpa_2021_1_889/startup.sh
ExecStop=sh /var/opt/solarwinds/dpa_2021_1_889/shutdown.sh

[Install]
WantedBy=mulit-user.target

This 'service' file should allow me to use systemctl start|enable|status|stop dpa like a 'regular' Linux service.

However, this doesn't really work for me.  I send the calls and the service never starts.  If I execute the script "traditionally" it starts fine.

I'm missing something here and it's outside my knowledge.  I'm asking the smarter Linux people here for help.

Thanks THWCKsters.

  • First off I noticed you had a typo in line 15, mulit should be multi.

    I also found this service file on GitHub and updated line 7 and 8 with the correct path of my DPA install. So far so good.

    https://gist.github.com/JPablomr/8d4c10332f5820b7aa5dfe6b2773ceaf

  • Yep - I totally missed that typo (not unusual for me after a long day on a keyboard).  It's funny how much we've gotten used to the squiggly red lines to point out our missteps.

    I swapped that out, changed the paths and it's still not working for me.  At this point, I'm being an absolute SolarWinds nerd and monitoring the executables via Orion and then building a script to execute the service if it sees it's not running.

    It's super rare that I have to worry about this since it's in a VM and I just pause/save the VM if I need to do things and spin it back up it afterwards.

    I appreciate the assistance, but I think I need to tear into the startup.sh and shutdown.sh a little more since it's been 5 years since the GitHub example was published and several things have changed.  Thanks for the assistance!

  • Coming in very late here, but just in the process of setting up a new RHEL8 server for DPA, hopefully this will help someone.

    DPA 2021.3.7445 on RHEL8

    Created file dpa.service in /lib/systemd/system:

    	[Unit]
    	Description=Solarwinds Database Performance Analyzer (DPA)
    	After=network.target
    	StartLimitIntervalSec=0
    
    	[Service]
    	Type=forking
    	Restart=always
    	RestartSec=30
    	User=xxxxx
    	ExecStart=[install path]/dpa_2021_3_7445/startup.sh
    	ExecStop=[install path]/dpa_2021_3_7445/shutdown.sh
    
    	[Install]
    	WantedBy=multi-user.target

    For SELinux - the start and stop scripts SELinux default security label should be usr_t or it will not run under systemctl:

    /sbin/restorecon -v [install path]/dpa_2021_3_7445/startup.sh
    /sbin/restorecon -v [install path]/dpa_2021_3_7445/shutdown.sh
    
    chmod o+r dpa.service
    
    systemctl daemon-reload
    systemctl enable dpa.service
    
    systemctl start dpa.service
    systemctl status dpa.service

  • This is some nice but, it should be noted that if this is used then this file does need as written to be also updated on any DPA upgrade as the steps in standard update documentation do not mention this added custom item at all and an upgrade places DPA in a new path. So this file would also need to be changed on any update and this doesn't get mentioned in the default Linux update instructions.