Skip to content

Deployment Recipes

Rowdy edited this page Apr 15, 2021 · 13 revisions

Deployment recipes, initially focussed on the TridentFleet pilot.

Note that much of this is now irrelevant since deployment under Docker has become more widespread.

Contents

  1. Abstract
  2. Linux server configuration - firewall
  3. Linux server configuration - systemd
  4. Deployment to Linux
  5. References
  6. TODO

Abstract

This document provides some brief notes that may be useful for the deployment of TG-based applications, and were initially created whilst deploying the TridentFleet pilot.


Linux server configuration - firewall

This is suitable for CentOS 7.1.

This only needs to be done once per server - provided the changes are made permanent they will take effect each time the server is rebooted.

  1. Login as, or become, root:

    $ su -
    
  2. Identify the active firewall zones:

    # firewall-cmd --get-active-zones
    

    For example:

    # firewall-cmd --get-active-zones
    public
      interfaces: eth0
    
  3. Determine if the port is already open:

    # firewall-cmd --zone=public --query-port=<port>/<protocol>
    

    Or if it is a known service:

    # firewall-cmd --zone=public --query-service=<service>
    

    For example:

    # firewall-cmd --zone=public --query-port=80/tcp
    no
    # firewall-cmd --zone=public --query-service=http
    no
    
  4. Add the specific port:

    # firewall-cmd --permanent --zone=public --add-port=<port>/<protocol>
    

    Or if it is a known service:

    # firewall-cmd --permanent --zone=public --add-service=<service>
    
  5. Reload the firewall to take effect:

    # firewall-cmd --reload
    

Linux server configuration - systemd

This is suitable for CentOS 7.1, but should also work for any other system using systemd.

This only needs to be done once per server - provided the service is appropriately configured it will start automatically each time the server is rebooted.

  1. Login as, or become, root:

    $ su -
    
  2. Create a user <username>, which will be used to run the service:

    # useradd -m <username>
    

    Note that the -m option will create the user's login directory under /home. To create a user with a specific login directory:

    # useradd -d /path/to/dir <username>
    
  3. Create the file /etc/systemd/system/<name>.service with content like:

    [Unit]
    Description=<name> Service
    After=network.target
    
    [Service]
    Type=simple
    User=<username>
    ExecStart=/path/to/executable --options
    Restart=on-abort
    
    [Install]
    WantedBy=multi-user.target
    

    After=network.target - specifies that the service should start after the network is available.

    Type=simple - other options are forking, oneshot, dbus, notify or idle.

    ExecStart=... - specifies the executable file or script that should be used to start the service. This does not set the working directory, so it is suggested to use a shell script that initially sets the working directory, then starts the application as required.

    Restart=on-abort - specifies that the service should be automatically restarted should it terminate uncleanly. Other options are no, on-success, on-failure, on-abnormal, on-watchdog, or always. no is probably the only other suggested option, which does not restart the service should it terminate for any reason.

    WantedBy=multi-user.target - starts the service when the system boots into multi-user mode (i.e. boots normally).

  4. Configure the service to start at boot:

    # systemctl enable <name>
    
  5. Start the service immediately:

    # systemctl start <name>
    
  6. Allow the service sufficient time to start, and check its status:

    # systemctl status <name>
    

Deployment to Linux

This is suitable for CentOS 7.1.

  1. Receive a zip file for deployment.

  2. Transfer the zip file to the server.

  3. As root, stop the service:

    # systemctl stop <name>
    
  4. Rename or archive the old version.

  5. Extract the new version into the same directory or, if extracted into a different directory, ensure that the startup script is altered accordingly.

    This document does not cover changing the systemd service configuration to cater for placement of the startup script in a different location.

  6. As root, start the service:

    # systemctl start <name>
    
  7. Allow the service sufficient time to start, and check its status:

    # systemctl status <name>
    

References


TODO

  • Nothing.
Clone this wiki locally