A set of shell scripts & systemd units to manage ET servers on a Linux machine.
- Systemd integration to easily manage the server.
- Each server starts up with a tmux session, to provide interactive server console.
- Automatic recovery on crash - if a server crashes, it will automatically restart after 5 seconds.
- Automatic crashlog generation - if the server has a logfile, it will be automatically saved in the event of a server crash.
- Configurable auto-restarting of servers on schedule, to work around high uptime issues.
Once installed and configured, the basic usage is as follows.
Starting, stopping and restarting servers should be done via systemctl.
# start a server
$ systemctl start etserver@<instance>.service
# stop a server
$ systemctl stop etserver@<instance>.service
# restart a server
$ systemctl reload etserver@<instance>.serviceNote that you can use reload rather than restart to restart the server - this keeps the tmux session alive in the background, and just performs a restart within the existing session session.
If you are not using systemd to manage the servers, the commands above map to the following inputs to the wrapper script.
# start a server
$ ./et-server.sh start <instance>
# stop a server
$ ./et-server.sh stop <instance>
# restart a server
$ ./et-server.sh restart <instance>You can attach to the server console of a running instance via tmux.
$ tmux a -t <instance>
# Or if you are logged in on a different user
$ sudo -u <user> tmux a -t <instance>- Configure a new instance in the
instancesdirectory. - Enable and start the systemd service to start the server.
$ systemctl enable etserver@<instance>.service $ systemctl start etserver@<instance>.service # or both with a single command $ systemctl enable --now etserver@<instance>.service
- Optionally configure the server to automatically restart periodically.
$ systemctl enable --now etserver-restart@<instance>.timer
Since everyone has their own way of setting up users and directory structures for their servers, there is some configuration required to get started. The repository is set up as following.
- Servers are managed by a user called
etserver. - The user
etserverhas a homepath in/srv/et.
You do not need to follow this structure, provided you modify the files to fit your environment. To adjust it to your environment, perform the following steps.
- Copy the
scriptsdirectory and it's content to your user's$HOME. - Edit the paths defined in
scripts/paths.shto match your environment.
⚠️ IMPORTANT⚠️
If you decide to locate the scripts somewhere else other than$HOME/scripts, you must edit bothscripts/et-server.shandscripts/run-server.shfiles too. Both files try to source thepaths.shscript from$HOME/scripts/directory, and will fail if they are unable to find it.
Configure your instance files in the directory defined in scripts/paths.sh. By default, this is setup to be $HOME/instances. The repository provides an example instance file.
If you opt to not use systemd to manage the servers, you may skip this step.
The entire etc directory can be copied onto the root directory of your machine - the paths map to a standard Linux server file structure. Once installed, the following steps should be taken to set everything up.
- Modify
/etc/systemd/system/etserver@.service:- Setup the correct path to
et-server.shscript. - Setup correct user/group to run the services as.
- Setup the correct path to
- If you wish to setup automatic restart on a timer, modify
/etc/systemd/system/etserver-restart@.timer:- Setup the timer to your liking. By default, this is setup to restart every day at 05:00 (5am).
- Modify
/etc/tmpfiles.d/etserver.conf. Note that if you setupSTATE_PATHto point to a directory you already have write access to, you can skip this entirely.- Setup the correct path for runtime temp files, if you modified
STATE_PATHinsidescripts/paths.sh. - Setup the directory to be owned by the correct user/group.
- Setup the correct path for runtime temp files, if you modified
If everything is setup correctly, you should now be able to start the server(s).
$ systemctl enable --now etserver@<instance>.service
# optional, setup periodic auto-restart
$ systemctl enable --now etserver-restart@<instance>.timerIf you are not using systemd, run scripts/et-server.sh directly.
$ ./et-server.sh start <instance>If everything succeeds, the server is now setup to automatically start when the server starts up. You may access the server console via tmux session.
$ tmux a -t <instance>
# Or if you are logged in on a different user
$ sudo -u <server-username> tmux a -t <instance>