Deployment Recipes - fieldenms/tg GitHub Wiki
Note that much of this is now irrelevant since deployment under Docker has become more widespread.
- Abstract
- Linux server configuration - firewall
- Linux server configuration - systemd
- Deployment to Linux
- References
- TODO
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.
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.
-
Login as, or become, root:
$ su -
-
Identify the active firewall zones:
# firewall-cmd --get-active-zones
For example:
# firewall-cmd --get-active-zones public interfaces: eth0
-
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
-
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>
-
Reload the firewall to take effect:
# firewall-cmd --reload
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.
-
Login as, or become, root:
$ su -
-
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>
-
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 areforking
,oneshot
,dbus
,notify
oridle
.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 areno
,on-success
,on-failure
,on-abnormal
,on-watchdog
, oralways
.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). -
Configure the service to start at boot:
# systemctl enable <name>
-
Start the service immediately:
# systemctl start <name>
-
Allow the service sufficient time to start, and check its status:
# systemctl status <name>
This is suitable for CentOS 7.1.
-
Receive a zip file for deployment.
-
Transfer the zip file to the server.
-
As root, stop the service:
# systemctl stop <name>
-
Rename or archive the old version.
-
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.
-
As root, start the service:
# systemctl start <name>
-
Allow the service sufficient time to start, and check its status:
# systemctl status <name>
- Nothing.