GroundWork recommends having the GroundWork Monitor application start on system reboot or power on. This allows you to ensure that monitoring automatically starts after power failures or crashes that require a reboot of the host that runs the GroundWork Monitor containers. Doing so entails adding a unit file to restart the system with docker-compose.  

Using this method is necessary due to the fact that GroundWork containers have specific timing dependencies, which are handled in the docker-compose.yaml file. While Docker experts may point out that it is possible to use Docker's own daemon to restart containers, we have found that doing so is not as reliable as using the system control scripts.  

Add the gw8.service file to /etc/systemd/system

  1. Log in as a privileged user (with sudo rights) to your GroundWork server.

  2. If you are not using the user you used to install GroundWork 8, then become that user, (e.g., if you installed as user gwos):

    sudo su - gwos
  3. Check where the docker-compose binary is by typing: 

    which docker-compose
  4. This will give you a path to the binary of docker-compose, for example: 

    which docker-compose
  5. Type exit to become the user with sudo access if necessary.

  6. If docker-compose is not at /usr/bin/docker-compose, then add a symlink to that location, for example: 

    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  7. Edit the /etc/systemd/system/gw8.service file:

    This file may or may not exist, depending on whether you have previously installed GroundWork Monitor. 

  8. Insert the following content: 

    # GW8 systemd service unit file.
    # Configure WorkingDirectory and User/Group below and place into
    # /etc/systemd/system directory. WorkingDirectory should be set
    # to the GW8 installation directory (where docker-compose.yml
    # has been set up). User must be a member of the docker group for
    # permission to access the docker daemon and have access to the
    # GW8 installation directory.
    # To enable:      sudo systemctl enable gw8
    # To start:       sudo systemctl start gw8
    # Show status:    sudo systemctl status gw8
    # To stop:        sudo systemctl stop gw8
    # To disable:     sudo systemctl disable gw8
    # To reconfigure: sudo systemctl daemon-reload
    Description=GW8 docker compose service
    # Daemon service type
    # Configure to match GW8 installation
    # Prune docker system
    ExecStartPre=/usr/bin/docker system prune -f
    # Compose up
    ExecStart=/usr/bin/docker-compose up -d
    # Compose down
    ExecStop=/usr/bin/docker-compose down
  9. Edit the lines for WorkingDirectory, User and Group to mach your installation. For example, if you installed GroundWork 8 in the /home/gwos directory as user gwos, and added the gwos user to the docker group, then these lines would look like this: 

  10. Save the file.

  11. Change the ownership of the file to be user root, group root: 

    sudo chown root:root /etc/systemd/system/gw8.service
  12. Enable the service: 

    sudo systemctl enable gw8
  13. If you have the authority to pause monitoring, reboot the host as a test. When it comes up, log in as the user you installed GroundWork as, then go to the gw8 directory, and enter: 

    docker-compose ps
    • You should see a listing of the GroundWork Monitor containers, all with Status "Up".

Related Resources