Restart script

REDIRECT: This URL has changed to https://support8.gwos.com/gw/gw8/latest/welcome-to-groundwork-monitor/installation/new-install/restart-script
Click the link above if you are not automatically redirected in 10 seconds.

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

Script vs. Docker daemon

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 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 that 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
    /usr/local/bin/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 file: /etc/systemd/system/gw8.service

    Previous install

    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
    
    [Unit]
    Description=GW8 docker compose service
    Requires=docker.service
    After=docker.service
    
    [Service]
    # Daemon service type
    Type=oneshot
    RemainAfterExit=yes
    
    # Configure to match GW8 installation
    WorkingDirectory=
    User=
    Group=
    
    # 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
    
    [Install]
    WantedBy=multi-user.target
  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: 

    WorkingDirectory=/home/gwos/gw8
    User=gwos
    Group=docker
  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 type: 

    $ docker-compose ps

    You should see a listing of the GroundWork Monitor containers, all with Status "Up".