└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # How to Manage a Garry's Mod Server 2 | 3 | Welcome to "How to Manage a Garry's Mod Server", here I will try to explain the process of managing a Garry's Mod server properly with the aim of productivity and scale over time. I am sick of seeing populated servers with horrible development practices and even more so, tired of working for them, so read this guide and fix your shit. 4 | 5 | Disclaimer, all of the information in this README was gathered from my own personal experience. I built and managed a successful Garry's Mod server in the past and continue to do commissions for other servers in the community. 6 | 7 | ## The Explanation 8 | 9 | ### 1. Github 10 | You need Github. Plain and simple. You will want to use Github for two main reasons, although there are many many more reasons why Github should be used. 11 | 1. Github allows you to store a backup for every single update and every single line of code you change. This means, if you fuck shit up, you can easily revert back. 12 | 2. Git's source conrol allows working with future developers, or any development you and your team contributes, much easier to manage and deploy as you can have mulitple people working on the same project at a time. 13 | 14 | If you plan to hire a developer for any commission work, a Github repository is a MUST. **DO NOT** hire anyone for commission work without this step. 15 | 16 | ### 2. Local Dedicated Server 17 | You will want to set up a local dedicated server, this will be your dev server. Any future work YOU do should be done through this server. **DO NOT** use FTP to update your code, that is very bad practice. 18 | 19 | Hosting the server yourself is free and allows you to develop much faster. 20 | 21 | It is also what we will be using to store your local github repository branch so you can make updates to your live server without ever touching or modifying any of the files, only your local files. 22 | 23 | ### 3. DeployHQ 24 | DeployHQ makes it easy to deploy your github repository to the live server. What this means is any updates you or your team makes can be pushed to the live server with a click of a button. 25 | This allows us to take the changes you've made in your local server and send them to the live server to be updated. DeployHQ is free, but limited to 5 deploys a day. As long as you have a decent update routine, this won't be an issue. 26 | 27 | ## The Setup 28 | 29 | ### 1. Github 30 | 1. Start by creating a Github account if you don't have one already. 31 | 2. Create a new Github Organization with your ServerName/CompanyName. 32 | 3. Create a new Private Reposiory for the Gamemode you are developing under that organization. Make sure it is set to Private. 33 | 34 | It should look something like this **github.com/MoonNetwork/DarkRP** 35 | ![image](https://user-images.githubusercontent.com/48765827/236049473-f81edb99-3612-4a4e-bfc7-102891d84040.png) 36 | 37 | Next we need to set up the local server before going any further with Github. 38 | 39 | ### 2. Local Dedicated Server 40 | 1. First you need to install SteamCMD. SteamCMD is used to download/update the Garry's Mod game. You can go [here](https://developer.valvesoftware.com/wiki/SteamCMD), scroll down to Download, and following the instructions for your OS. 41 | 2. Create a new directory for your server located in a safe location and name it whatever you want. I.e. "MoonNetworkDarkRP". Save the location of this directory as you will need it for the next step. 42 | 3. Go to where you installed SteamCMD and open it. The first time you open the program, it will download all of the required files for it to run. Once it has finished, type in these commands in order: 43 | ``` 44 | force_install_dir 45 | login anonymous 46 | app_update 4020 validate 47 | ``` 48 | 49 | This will install the Garry's Mod Dedicated Server in that directory, now we need to configure it. 50 | 51 | 4. Create a new file in the root directory of the installed garry's mod server, name it `start.bat`. 52 | 5. Open it and paste these contents, but make sure to replace the with your own. 53 | ``` 54 | start "SRCDS" /B srcds.exe -game garrysmod -conlog -port 27015 -console -conclearlog -condebug -tvdisable -maxplayers 16 +gamemode +r_hunkalloclightmaps 0 +map -tickrate 26 +fps_max 26 +host_workshop_collection "" +sv_lan 0 55 | ``` 56 | 57 | Now if you run `start.bat`, a terminal should open and the server should start. If it doesn't run, then congratulations you failed. 58 | 59 | Now that we have the server installed, we must set up our github repository with the `addons` folder. 60 | 61 | If you already have a live server with addons installed, now is the time to copy everything from the live server to your local server, only the `addons` folder. 62 | 63 | 6. Open a terminal in your local server's `addons` directory. You can do this by right cicking in the directory and clicking "Open in Terminal". 64 | 7. Type in these commands to initialize the github repository with the repository you made. 65 | ``` 66 | git init 67 | git remote add origin 68 | git fetch 69 | git checkout main 70 | git add . 71 | git commit -m "init" 72 | git push origin main 73 | ``` 74 | 75 | This will initialize a new repository, set it up with the repository you made, fetch any files the repo may have, add the files we already had, and push it to git. 76 | 77 | Congratulations, you created a repository and are now backing up your server files. Let's move on and set up DeployHQ. 78 | 79 | ### 3. DeployHQ 80 | 81 | 1. Go to https://deployhq.com/ and create a new account. 82 | 2. Sign into your deploy panel and you should be greeted with a "Create a Project" screen. 83 | ![image](https://user-images.githubusercontent.com/48765827/236048057-9feccc4b-5b6a-40ab-9896-f31c2ffdb043.png) 84 | 3. Fill out the server information and select Github, click Create Project. 85 | ![image](https://user-images.githubusercontent.com/48765827/236048127-42c75682-93bf-43f3-aa95-d4fe53795488.png) 86 | 4. You should be able to link your Github account to your DeployHQ account, allowing you to select the Server's Repository. 87 | ![image](https://user-images.githubusercontent.com/48765827/236048298-4e0558ad-8cd0-47b2-b0e5-9fd46824b0e6.png) 88 | 5. Now we must link the repository to the live serve so updates can be pushed. Fill out the New Server form with your server's connection info. For Physgun servers, use SSH/SFTP. 89 | ![image](https://user-images.githubusercontent.com/48765827/236048546-0a308b64-6208-4bd1-ba5b-3511c8f16e83.png) 90 | 6. On the bottom of the page, you should see Deployment Path as an option. This will be the directory the repository is updating the files to. For Physgun servers, this should be `/garrysmod/addons`, though it could differ depending on the server's host. Now you can click Create Server. 91 | ![image](https://user-images.githubusercontent.com/48765827/236048822-14f0cbfa-2ee2-4caf-9854-db063c3aba60.png) 92 | 93 | If you didn't get any errors then great, it worked. Otherwise, you're going to have to debug the problem. 94 | 95 | Now whenever we want, we can go to the deploy's overview page and click New Deployment. This will allow you to update the server with the latest commit, which should be "init". Go ahead and run the first deployment so DeployHQ is synced with what files we have on the server. 96 | 97 | Check FTP and make sure all the files are in the correct place. Great, this is probably the last time you'll need to use FTP. 98 | 99 | ### 4. IDE (Visual Studio Code) 100 | 101 | You will most likely want an IDE, in this case Visual Studio Code, to manage/update your files. Visual Studio Codes makes things easier by having a built-in Source Control window which shows every change you've made on that commit. It's helpful for those times you forget what you've changed and want to look back and verify everything is good. It can also be helpful for mass-finding a function or string that is messing up. Just click `Ctrl + Shift + F` to search through every file. 102 | 1. Download and install Visual Studio Code [here](https://code.visualstudio.com/) 103 | 2. Now you can open your addons directory in VSCode and boom, you have the power of FTP all in one editor! 😎 104 | 105 | ## The Conclusion 106 | 107 | Now that we have the Github Repository storing the server files, the DeployHQ account ready to push our changes to the live server, and the dedicated server to make the changes on, we just need to put it all together. 108 | 109 | ### Development Flow 110 | 1. Open your server's `addons` directory in VSCode. You can either open a terminal in the addon's directory and type `code .` or you can right click in the directory and click 'Open with Code'. 111 | 2. Make a change, or changes. 112 | 3. Push changes to Github: 113 | ``` 114 | git add . 115 | git commit -m "feat: my changes" 116 | git push origin main 117 | ``` 118 | 4. Go to your DeployHQ overview and click `New Deployment`. Click Deploy to deploy your latest commit to the sever. 119 | 120 | And that's it, you just updated the live server with your local server's files! 121 | 122 | ## Bonus! 123 | When commiting to github, you have to type 3 commands that are hard to remember every time. Make this process easier by installing my Github CLI, [Boom](https://www.npmjs.com/package/@steelio/boom-cli). 124 | 125 | This cuts down the pushing process from this: 126 | ``` 127 | git add . 128 | git commit -m "feat: my changes" 129 | git push origin main 130 | ``` 131 | To only this: 132 | ``` 133 | boom push "feat: my changes" 134 | ``` 135 | 136 | 1. Start by installing NodeJS, [here](https://nodejs.org/en) You may have to restart your computer after, I am not sure. 137 | 2. Now install the Boom package with this command: 138 | ``` 139 | npm install -g @steelio/boom-cli 140 | ``` 141 | 3. Now close the terminal and open it back up and type `boom`. 142 | 143 | If it works then great, you successfully installed Boom. 144 | Now everytime you want to push an update, type `boom push "the update message"`! 145 | 146 | Thanks for reading this guide! I hope you found something useful in it. If you want to contribute, just make a PR ❤️ 147 | 148 | http://codesteel.io/ 149 | --------------------------------------------------------------------------------