This is a toolset to manage a production server of /tg/Station13 (and its forks). It includes the ability to update the server without having to stop or shutdown the server (the update will take effect next round) the ability start the server and restart it if it crashes, as well as systems for fixing errors and merging GitHub Pull Requests locally.
Generally, updates force a live tracking of the configured git repo, resetting local modifications. If you plan to make modifications, set up a new git repo to store your version of the code in, and point this script to that in the config (explained below). This can be on github or a local repo using file:/// urls.
Requires python 2.7/3.6 to be installed for changelog generation
- The old cmd script server can be found in the legacy tree
- Either compile from source (requires .NET Framework 4.5.2, Nuget, and WiX toolset 4.0) or download the latest release from github
- Unzip setup files
- Run the installer or use the console server
- Launch
TGControlPanel.exeas an administrator. A shortcut can be found on your desktop - Use the
Create Instancebutton to create a new server instance - Go to the
RepositoryTab and set the remote address and branch of the git you with to track. Note: To grab the tgstation repo, use the following URL: git://github.com/tgstation/tgstation.git - Hit the clone button
- While waiting go to the
BYONDtab and install the BYOND version you wish - You may also configure an IRC and/or discord bot for the server on the chat tab
- Once the clone is complete you may set up a committer identity, user name, and password on the
Repositorytab for pushing changelog updates - Go to the
Servertab and click theInitialize Game Foldersbutton - Optionally change the
Project PathSetting from tgstation to wherever the dme/dmb pair are in your repository - Optionally tick the Autostart box if you wish to have your server start with Windows
- When game folder initialization is complete, click the
Copy from Repo and Compileoption
This process is identical to the above steps in command line mode. You can always learn more about a command using ? i.e. repo ?
- Launch TGCommandLine.exe as an administrator (running with no parameters puts you in interactive mode)
service set-python-path C:\Python27(If Your Python Install is in Program Files, You must encase the path in Quotes, Ex: "C:\Program Files\Python36")service create-instance "TGS" D:\tgstationinstanceAnd enterTGS. If you aren't using interactive mode, the following commands must be suffixed with--instance TGSrepo setup https://github.com/tgstation/tgstation masterbyond update 511.1385irc nick TGS3Testirc set-auth-mode channel-modeirc set-auth-level %irc setup-auth NickServ "id hunter2"Yes this is the real password, please use it only for testingirc join botbus devirc join botbus adminirc join botbus wdirc join botbus gameirc enablediscord set-token Rjfa93jlksjfj934jlkjasf8a08wfl.asdjfj08e44See https://discordapp.com/developers/docs/topics/oauth2#botsdiscord set-auth-mode role-iddiscord addmin 192837419273409See how to get a role id: https://www.reddit.com/r/discordapp/comments/5bezg2/role_id/. Note that if youdiscord set-auth-mode user-idyou'll need to use user ids (Enable developer mode, right click user,Copy ID)discord join 12341234453235 devThis is a channel id (Enable developer mode, right click channel,Copy ID)discord join 34563456344245 devdiscord join 23452362574456 admindiscord join 23452362574456 wddiscord join 53457345736788 gamediscord enablerepo set-name tgstation-serverThese two lines specify the changelog's committer identity. They are not mirrored in the GUIrepo set-email [email protected]repo set-credentialsAnd follow the promptsdm project-name tgstationdd autostart onrepo statusTo check the clone job statusdm initialize --waitdd start
- Create windows accounts for those you wish to have access to the service
- Join them in a common windows group
- Run TGCommandLine.exe as an administrator
admin set-group <Name of the group you created> --instance "<instance name>"
Note: Due to internal functionality, a user who has access to at least one server instance will be able to view the metadata (Name, path, Logging ID, and Enabled status) of all instances.
- Obtain an SSL certificate to secure the connection (this is beyond the scope of this guide)
- Either stick with the default port
38607or change it withservice set-port <port #> - Bind the SSL certificate to the port
- e.g.
netsh http add sslcert ipport=0.0.0.0:<port #> certhash=<certificate hash> appid={F32EDA25-0855-411C-AF5E-F0D042917E2D} - The
appidGUID actually doesn't matter, but for sanity, you should use the GUID of TGServerService.exe as printed above - Power shell users remember to quit the appid:
netsh http add sslcert ipport=0.0.0.0:<port #> certhash=<certificate hash> appid="{F32EDA25-0855-411C-AF5E-F0D042917E2D}"as {} has special meaning in powershell
- e.g.
- Ensure the port can be acccessed from the internet
- Log in from any computer using a username and password from the service computer in either the CLI or GUI
The service supports updates while running a DreamDaemon instance. Simply install an updated version as you normally would and process ownership will transfer smoothly to the new service.
-
Game/<A/B>/- This will house two copies of the game code, one for updating and one for live. When updating, it will automatically swap them.
-
Static/- This contains the
data/andconfig/folders from the code. They are stored here and a symbolic link is created in theGamefolders pointing to here. - Resetting the repository will create a backup of this and reinitalize it
- This contains the
-
Game/Live/- This is a symbolic link pointing to current "live" folder.
- When the server is updated, we just point this to the updating folder so that the update takes place next round.
-
Diagnostics- This contains various timestamped diagnostic information for DreamDaemon invocations
-
Repository/- This contains the actual git repository, all changes in here will be overwritten during update operations.
-
RepoKey/- This contains ssh key information for automatic changelog pushing.
-
EventHandlers/- This contains batch files that run after certain events, currently only precompile and postcompile events are implemented. If you'd like an event handler you should create a file in this folder with the following name:
{event_name}.batfor example: if I want an event handler for precompile, I would name itprecompile.bat.
- This contains batch files that run after certain events, currently only precompile and postcompile events are implemented. If you'd like an event handler you should create a file in this folder with the following name:
-
BYOND/- This contains the actual BYOND installation the server uses
-
BYOND_staging/- This appears when a BYOND update is queued but can't currently be applied due to usage of the current BYOND version. It will be applied at the first possible moment. Restarting the service deletes this folder
-
BYOND_revision.zip- This is a queued update downloaded from BYOND, it will be unzipped into BYOND_staging and deleted. Restarting the service deletes this file
-
TGDreamDaemonBridge.dll- This is the .dll the TGS3 API
call()()s into to RPC the server instance that runs it - Instance -> DreamDaemon communication is achieved via
world/Topic()
- This is the .dll the TGS3 API
-
prtestjob.json- This contains information about current test merged pull requests in the Repository folder
-
TGS3.json- This is a copy of
TGS3.jsonfrom the Repository. If a repostory change creates differences between the two, update operations will be blocked until the user confirms they want to change it
- This is a copy of
-
Instance.json- The internal configuration settings for a server instance. Note that access to this file bypasses API user restrictions
To get the TGS3 API for your code base, import the 3 .dm files in the DMAPI folder into your include structure, then fill out the configuration as documented in the comments of server_tools.dm. Then, you may want to add a TGS3.json file to specify any static directories and .dlls your codebase uses, along with the optional changelog compile options. Any changes to TGS3.json will block compiler operations until a server operator manually approves them.
To run the game server, open the Server tab of the control panel and click either Start
It will restart the game server if it shutdowns for any reason, giving up after 5 tries in under a minute
To update the server, open the Server tab of the control panel. Click Update Server. (it will git pull, compile, all that jazz). Note that this button won't clear test merges.
(Note: Updating automatically does a code reset, clearing ALL changes to the local git repo, including manual changes (This will not change any data in the Static/ folder))
Updates do not require the server to be shutdown, changes will apply next round if the server is currently running.
All DM compilation will log to the server what commit they happened at and create a backup tag in the local repository.
This feature currently only works if github is the remote (git server).
Running these will merge the pull request then recompile the server, changes take effect the next round if the server is currently running.
There are two flavors to this.
- The manual method is to use the repo page's merge PR button for fine grain control over PR merging. Each time this button is pressed, the latest commit of the specified PR# will be merged into the repo
- The managed method is the Server page's
Test Merge Managerwhich uses the GitHub API to get information about available PRs.- Open PRs are listed by default
- Currently test merged PRs are checked off and listed at the top when it's opened
- If a PR contains a label that contains the text
test(case-insensitive) it will be listed on top and marked asTESTING REQUESTED- If a PR has been updated since it was test merged, two entries for it will appear. One listed as
OUTDATEDand specifying the commit it was merged at - You can change the initial update action of the server with the radio buttons in the bottom left.
Update to Remotefully resets and updates the server before merging PRs.Update To Origindoes the same based off the local repository'soriginremote.No Updatewill merge the PRs without any prior action - Checking off PRs here and then hitting apply will run the selected update action, optionally generate and push a changelog (see below), merge the PRs, and then compile.
Update Serverwill keep any active merged PRs until they are manually removed or merged on theoriginremote. - Given that the control panel uses GitHub's API to populate the
Test Merge Manageryou may be prompted for your credentials if you make too many requests. This will create a personal access token with public access on your account specifying its use to bypass the GitHub API rate limit.
- If a PR has been updated since it was test merged, two entries for it will appear. One listed as
You can clear all active test merges using Reset to Origin Branch in the Repository tab and the using Copy from Repo and Compile in the server tab (explained below). You can also use the Reset All Test Merges button on the server tab for a concise solution.
Server->Copy from Repo and Compile- Copies the local repository code, compiles it, and stages it to apply next round
Server->Initialize Game Folders- Requires the server not be running, rebuilds the
Gamefolder and then doesCopy from Repo and Compile - Required on first setup
- Requires the server not be running, rebuilds the
Just tick the Autostart option in the Server tab or run dd autostart on on the command line. As it's a windows service, it will automatically run without having to log ing
Just tick the Webclient option in the Server tab or run dd webclient on on the command line.
- The
Static Filespage of the control panel lets you modify all files in directories you specified inTGS3.json - The files are modified here using the Windows credentials of the active user, feel free to manually set ACLs on them
- You may optionally rebuild the entire
Staticfolder from the repository using theRecreate Static Directorybutton. This will copy the original files from the repository based on the currentTGS3.json. This requires DreamDaemon not be running
Any .dm files included in the root level of the Static directory are automatically copied over and included before anything else in your .dme for compilation. Use this to configure compile options as you see fit.
- Instances can be renamed, but this requires a temporary offlining of them (this includes interface access, DreamDaemon, and chat bots)
- Detaching an instance simply removes it from the main server's configuration and control, leaving it free for the user to manipulate
- Importing an instance will work as long as
- No other instance currently in the server has the same name
- It is not the same path as another instance Note that importing an instance as a different windows user (this is always different across machines) will result in a loss of chat configuration due to the encryption scheme
- Service logs are stored in the Windows event viewer under
Windows Logs->Application. You'll need to filter this list forTG Station Server - Every event type is keyed with an ID. A complete listing of these IDs and their purpose can be found here. Event IDs from different instances are offset by the logging ID the instance was assigned when it was started.
- You can also import the custom view
View TGS3 Logs.xmlin this folder to have them automatically filtered - Servers running in console mode only use std_out
- The repository will automatically create an ssh version of the initial origin remote and can optionally push generated changelogs to your git through it
- The repository can only authenticate using ssh public key authentication
- To enable this feature, simply create
public_key.txtandprivate_key.txtin a folder called RepoKey in the server directory - The private key must be in
-----BEGIN RSA PRIVATE KEY-----format and the public key must be inssh-rsaformat. You can generate a keypair like this using the converter in the dropdown menu of PuTTYGen. See github guidelines for setting this up here: https://help.github.com/articles/connecting-to-github-with-ssh/ - The server will be able to read these files regardless of their permissions, so the responsibility is on you to set their ACL's so they can't be read by those that shouldn't
- An instance can push branchless test merge commits to GitHub if the
RepoKeyfolder is setup - This pushes all test merge commits to the remote branch
___TGS3TempBranchand then deletes it - This provides public reference information about the test merge commit and time since it will appear in the PR in questing
- To enable this, check the
Sync Commitsbutton on theRepositorypage of the control panel or runrepo push-testmerges on --instance "<instance name>"from TGCommandLine
- See CONTRIBUTING.md
- The DM API for the project is licensed under the MIT license.
- The /tg/station 13 icon is licensed under Creative Commons 3.0 BY-SA.
- The remainder of the project is licensed under GNU AGPL v3
See the bottom of each file in the /DMAPI tree for the MIT license

