Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Add new branch to work with Docker #256

Draft
wants to merge 49 commits into
base: master
Choose a base branch
from

Conversation

gmargriff
Copy link

Hi, I'm working in this project's Docker support. Hope anyone can better test it's compatibility with current client. Had to make a few changes in server files so that it's compatible with Linux + works with docker initialization. It would be better to keep this in a separate Docker branch for now. Thanks!

@exectails
Copy link
Member

Thanks for sharing your work. We wouldn't want to merge this into the main branch, but keeping it in a seperate one might be a nice idea. Though there are a couple changes I'm personally not happy with, such as merging all SQL files or removing the console command code entirely. I feel like we'd want to keep as much of the code the same as possible, without major differences between versions/branches.

Syncing last repo changes
Allow usage of command inputs on baremetal Windows OS while keeping disable for incompatible systems (UNIX + Docker and MacOS)
@gmargriff
Copy link
Author

Thanks for sharing your work.

Thank you for your project, dedication and for taking the time to review this fork.

We wouldn't want to merge this into the main branch, but keeping it in a seperate one might be a nice idea.

Yeah, I think it's quite a change of scope to be merged straight to master.

Though there are a couple changes I'm personally not happy with, such as merging all SQL files or removing the console command code entirely.

I agree, I did the SQL merge because it's easier to setup the Docker entrypoint with one file, but there was no good reason to remove the original files. The console commands shouldn't have been removed either, so I've added a feel checks to skip incompatible commands on incompatible systems whille keeping it working as intented on Windows baremetal OS.

I feel like we'd want to keep as much of the code the same as possible, without major differences between versions/branches.

Also agreed. I'll try to keep up!

@@ -0,0 +1,11 @@
# ENVIRONMENT determines the folder where we'll look for binaries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it would be beneficial to include a brief explanation of what this file is, for anyone who might look inside without knowing about Docker.

README.md Outdated
@@ -41,23 +35,105 @@ Specifically, some of the major features that are working are as follows:
- Monster spawns
- Quests

Requirements

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While a guide for the setup via Docker is of course a good idea, I think it's a bit excessive for the readme, which, in my opinion, should be more of a summary for the application as a whole. We also don't include a detailed guide on setting up the client for the same reason. Such information is better suited for the wiki. Or better yet, our underutilized doc folder,

@@ -0,0 +1,10 @@
FROM ubuntu:22.04
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the name of this folder could be chosen better, as "Servers" has a rather general purpose ring to it, that seems misleading, seeing how it's only used for Docker.

ConsoleUtil.LoadingTitle();

// Skip the following command on incompatible systems
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually an issue? Does it throw an exception if ran through Docker or something? If so, we'd probably rather want to make this a general check inside the LoadingTitle method, where we make sure there's actually a window that we can change the title of.

new BarracksConsoleCommands().Wait();
// If running on Windows system, enable console inputs
// otherwise, start an event loop to keep server running until stopped
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the check for Windows is misguided here, because I could also be running Melia under Linux or MacOS for example, without using Docker. Instead, a check for an interactive console would seem more appropriate.

{
if (serverUpdateMessage.ServerType == ServerType.Zone)
_zoneServerNames[sender] = serverUpdateMessage.ServerId;
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your auto-formatter seems to have intended a the switch cases, which is somewhat undesirable. Please make sure it's operating according to our coding conventions.

@@ -19,7 +19,7 @@ public void Load(string filePath)
{
this.Include(filePath);

this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe"));
this.PhpCgiFilePath = this.GetString("php_cgi_bin", "/usr/bin/php-cgi");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing the default values of the configs, wouldn't it be cleaner to just change the user conf values during the Docker setup? It wouldn't have to mess with the system conf at all.

start Outdated
@@ -0,0 +1,56 @@
#!/bin/sh
killall -9 BarracksServer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this bash script could more or less serve the purpose of the batch scripts we have, which is good for Linux users, but it probably shouldn't kill all servers on start for that to work, because you would then not be able to spin up new servers, or restart one for example, without killing all of them.

stop Outdated
@@ -0,0 +1,7 @@
#!/bin/sh
clear
Copy link
Member

@exectails exectails Jul 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might just be me, but I think I'd be a bit annoyed if the stop script cleared my screen every time. What if there was still something I needed?

user : root
pass :
pass : 123456
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with the PHP options, you don't need to modify the system configs if you just create the respective user conf files.

@exectails
Copy link
Member

I believe if those couple things are improved upon, this is basically fine to be merged into a branch, or even master, if it manages to be general purpose enough.

@y4my4my4m
Copy link

fyi, under windows, i had to add vim to the packges of the dockerfile and do :set ff=unix to the start file because it was copying the file to the docker with non-unix CLRF file ending

@y4my4my4m
Copy link

y4my4my4m commented Aug 9, 2024

gmargriff#4
I made a PR to @gmargriff 's repo (because im using the docker version for convenience) but thought the docker ver should get merged in the main repo too. If the docker doesnt get merged, maybe you'd still like to add my changes.

@y4my4my4m y4my4my4m mentioned this pull request Aug 13, 2024
Copy link
Member

@exectails exectails left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the continued work on this PR. I'd like to merge it in the near future, but unfortunately there are still some issues and potential improvements, as well as comments that weren't addressed yet.

@@ -17,8 +18,12 @@ public class WebConfFile : ConfFile
public void Load(string filePath)
{
this.Include(filePath);

this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe"));
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't really change anything, because the configuration value is read from the conf file regardless of the operating system. The only way you will get the usr bin path from this is if the conf option is missing.

@@ -63,7 +63,21 @@ public ChatCommands()
this.Add("item", "<item id> [amount]", "Spawns item.", this.HandleItem);
this.Add("silver", "<modifier>", "Spawns silver.", this.HandleSilver);
this.Add("spawn", "<monster id|class name> [amount=1] ['ai'=BasicMonster] ['tendency'=peaceful] ['hp'=amount]", "Spawns monster.", this.HandleSpawn);
this.Add("madhatter", "", "Spawns all headgears.", this.HandleGetAllHats);

this.Add("madhatter", "", "Spawns all hair accessories.", this.HandleGetAllHairAccessories);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't related to the docker PR, is it? 🤔

ConsoleUtil.LoadingTitle();

// Skip the following command on incompatible systems
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We since fixed the problem with LoadingTitle under Linux, and this should now work without any exceptions made in the code.


// If running on Windows system, enable console inputs
// otherwise, start an event loop to keep server running until stopped
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a suboptimal thing to do, because if I'm running the server in a console under Linux, I might want console commands. In the same vein, I might run the server without a console on Windows. It seems to me like a check for an interactive environment would be more appropriate.

We actually have a property for that on ConsoleUtil, "IsUserInteractive", though I'll admit this property hasn't been used or confirmed to still be working in a while.

@@ -5,6 +5,6 @@
// Path to the PHP CGI executable
// If the file doesn't exist, and the configured path is in user/tools/,
// PHP is downloaded automatically on Windows.
php_cgi_bin: user/tools/php/php-cgi.exe
php_cgi_exe: /usr/bin/php-cgi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to have reverted a recent change here, where the name of the option was fixed. It was supposed to be _bin. Additionally, it would be better if, instead of changing default values in conf files in the system folder, you would dynamically make your changes in the user folder for Docker.

@@ -0,0 +1,8 @@
// Melia
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an example db conf file for Docker? Will this not be created during the setup process?

@@ -41,7 +35,116 @@ Specifically, some of the major features that are working are as follows:
- Monster spawns
- Quests

Requirements
Installation with Docker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer you revert the changes to the readme, which is supposed to be both concise and general purpose. Long explanations about the setup are better suited for the docs folder.

@@ -1,18 +1,17 @@
CREATE TABLE `character_etc_properties` (
`propertyId` bigint(20) NOT NULL,
CREATE TABLE IF NOT EXISTS `character_etc_properties` (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me what this change is about? I feel like we'd want this to fail if the table already exists, because that's an indicator for something not being right.

@gmargriff gmargriff marked this pull request as draft September 2, 2024 22:38
@gmargriff
Copy link
Author

Hey, @exectails and @y4my4my4m , thanks for your work in this PR, I've done just enough changes to make autosync available again on Github, but I'm not directly working on this right now since my PC has been down since may/june, just changed the PR to draft to avoid confusion. Through my phone I've been just keeping the repo synced. I've read through the comments here and it all seems reasonable, as soon as I can get back I'll be working on this. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants