mark2devel / mark2

Minecraft Multi Server Wrapper Written in Python with Twisted; Pull Requests HIGHLY Encouraged, Collaborators Needed Discord: https://discord.gg/zymJygHNpv
Other
205 stars 44 forks source link

mark2 config and jar list commands error #136

Closed Tellik closed 2 years ago

Tellik commented 2 years ago

Installation Path:

Started with cloning the git, and then ln -s the bin file. Verified that all packages were installed according to the Arch section:

warning: python-psutil-5.8.0-1 is up to date -- skipping
warning: python-urwid-2.1.2-1 is up to date -- skipping
warning: python-twisted-21.2.0-3 is up to date -- skipping
warning: python-service-identity-21.1.0-1 is up to date -- skipping
warning: python-feedparser-5.2.1-9 is up to date -- skipping
warning: python-pyopenssl-20.0.1-1 is up to date -- skipping
warning: xclip-0.13-3 is up to date -- skipping

Even though it isn't in the Arch section, I went ahead and pip installed the requirements.txt as well.

Requirement already satisfied: feedparser==6.0.8 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (6.0.8)
Requirement already satisfied: psutil==5.8.0 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (5.8.0)
Requirement already satisfied: pyOpenSSL==20.0.1 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (20.0.1)
Requirement already satisfied: Twisted==21.2.0 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 4)) (21.2.0)
Requirement already satisfied: urwid==2.1.2 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (2.1.2)
Requirement already satisfied: service_identity==21.1.0 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 6)) (21.1.0)
Requirement already satisfied: pyperclip==1.8.2 in /usr/lib/python3.9/site-packages (from -r requirements.txt (line 7)) (1.8.2)
Requirement already satisfied: sgmllib3k in /usr/lib/python3.9/site-packages (from feedparser==6.0.8->-r requirements.txt (line 1)) (1.0.0)
Requirement already satisfied: cryptography>=3.2 in /usr/lib/python3.9/site-packages (from pyOpenSSL==20.0.1->-r requirements.txt (line 3)) (3.4.7)
Requirement already satisfied: six>=1.5.2 in /usr/lib/python3.9/site-packages (from pyOpenSSL==20.0.1->-r requirements.txt (line 3)) (1.16.0)
Requirement already satisfied: attrs>=19.1.0 in /usr/lib/python3.9/site-packages (from service_identity==21.1.0->-r requirements.txt (line 6)) (21.2.0)
Requirement already satisfied: pyasn1-modules in /usr/lib/python3.9/site-packages (from service_identity==21.1.0->-r requirements.txt (line 6)) (0.2.8)
Requirement already satisfied: pyasn1 in /usr/lib/python3.9/site-packages (from service_identity==21.1.0->-r requirements.txt (line 6)) (0.4.8)
Requirement already satisfied: zope.interface>=4.4.2 in /usr/lib/python3.9/site-packages (from Twisted==21.2.0->-r requirements.txt (line 4)) (5.4.0)
Requirement already satisfied: constantly>=15.1 in /usr/lib/python3.9/site-packages (from Twisted==21.2.0->-r requirements.txt (line 4)) (15.1.0)
Requirement already satisfied: incremental>=16.10.1 in /usr/lib/python3.9/site-packages (from Twisted==21.2.0->-r requirements.txt (line 4)) (21.3.0)
Requirement already satisfied: Automat>=0.8.0 in /usr/lib/python3.9/site-packages (from Twisted==21.2.0->-r requirements.txt (line 4)) (20.2.0)
Requirement already satisfied: hyperlink>=17.1.1 in /usr/lib/python3.9/site-packages (from Twisted==21.2.0->-r requirements.txt (line 4)) (21.0.0)
Requirement already satisfied: idna>=2.5 in /usr/lib/python3.9/site-packages (from hyperlink>=17.1.1->Twisted==21.2.0->-r requirements.txt (line 4)) (3.2)
Requirement already satisfied: setuptools in /usr/lib/python3.9/site-packages (from zope.interface>=4.4.2->Twisted==21.2.0->-r requirements.txt (line 4)) (57.4.0)

So now that I'm sure I have the installation correct, hopefully, this is the problem where I'm at:

I went ahead and tried mark2 start, which told me it was unconfigured and to run the config. This is what I see when I try to run config.

Traceback (most recent call last):
  File "/usr/bin/mark2", line 6, in <module>
    sys.exit(main())
  File "/home/tellik/mark2/mk2/launcher.py", line 625, in main
    command.start()
  File "/home/tellik/mark2/mk2/launcher.py", line 126, in start
    self.run()
  File "/home/tellik/mark2/mk2/launcher.py", line 488, in run
    self.copy_config(src, dst)
  File "/home/tellik/mark2/mk2/launcher.py", line 427, in copy_config
    while l0.strip() == '' or l0.startswith('### ###'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

I also tried the other method, of making the directory /etc/mark2 and touching the mark2.properties to generate the file, that didn't work.

I get some other errors, but since it isn't configured completely I'll hold off on those.

Column01 commented 2 years ago

Seems python 2 rears its ugly head once again... seems that a method was changed to return a file object opened with bytes instead of being normal. Luckily I implemented a fix on my fork of mark2 for testing purposes to confirm it works for you Mind trying it out?

git remote add column https://github.com/Column01/mark2.git
git pull column master
mark2 config
Column01 commented 2 years ago

I will also need to update the arch guide, it was ported from the old one without testing as I run debian. Did using pip3 install -r requirements.txt suffice for adding them?

Tellik commented 2 years ago

I will also need to update the arch guide, it was ported from the old one without testing as I run debian. Did using pip3 install -r requirements.txt suffice for adding them?

Yes, either pip or pip3 worked and accomplished the same requirements. I'll check the forked fix here in a moment.

Tellik commented 2 years ago

Seems python 2 rears its ugly head once again... seems that a method was changed to return a file object opened with bytes instead of being normal. Luckily I implemented a fix on my fork of mark2 for testing purposes to confirm it works for you Mind trying it out?

git remote add column https://github.com/Column01/mark2.git
git pull column master
mark2 config
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 4 (delta 3), reused 4 (delta 3), pack-reused 0
Unpacking objects: 100% (4/4), 442 bytes | 442.00 KiB/s, done.
From https://github.com/Column01/mark2
  branch            master     -> FETCH_HEAD
  [new branch]      master     -> column/master
Updating 5201ca2..4669f21
Fast-forward
 mk2/launcher.py | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Perfect, works fine.

Config option pulls up nano with the config file, which is kind of weird because it shoves the mark2.properties in ~/.config/mark2/mark2.properties. I'm guessing that it no longer is needing /etc/mark2/*?

Running mark2 start (without changing anything) also works, says it can't find the server jar like I"d expect and stops. So I'll work on finishing this setup.

The other error that I'm seeing, probably because I'm doing it wrong, but it doesn't error out cleanly, is by running mark2 jar-list:

Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/twisted/internet/base.py", line 503, in fireEvent
    DeferredList(beforeResults).addCallback(self._continueFiring)
  File "/usr/lib/python3.9/site-packages/twisted/internet/defer.py", line 339, in addCallback
    return self.addCallbacks(callback, callbackArgs=args, callbackKeywords=kw)
  File "/usr/lib/python3.9/site-packages/twisted/internet/defer.py", line 330, in addCallbacks
    self._runCallbacks()
  File "/usr/lib/python3.9/site-packages/twisted/internet/defer.py", line 662, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
--- <exception caught here> ---
  File "/usr/lib/python3.9/site-packages/twisted/internet/base.py", line 515, in _continueFiring
    callable(*args, **kwargs)
  File "/home/tellik/mark2/mk2/launcher.py", line 565, in start
    d = servers.jar_list()
  File "/home/tellik/mark2/mk2/servers/__init__.py", line 121, in jar_list
    d = get_raw()
  File "/home/tellik/mark2/mk2/servers/__init__.py", line 87, in get_raw
    mod.ref(d)
  File "/home/tellik/mark2/mk2/servers/__init__.py", line 36, in __init__
    self.work()
  File "/home/tellik/mark2/mk2/servers/vanilla.py", line 8, in work
    self.get(self.base + 'versions.json', self.handle_data)
  File "/home/tellik/mark2/mk2/servers/__init__.py", line 39, in get
    d = getPage(str(url))
  File "/usr/lib/python3.9/site-packages/twisted/python/deprecate.py", line 298, in deprecatedFunction
    return function(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/twisted/web/client.py", line 814, in getPage
    return _makeGetterFactory(
  File "/usr/lib/python3.9/site-packages/twisted/web/client.py", line 760, in _makeGetterFactory
    uri = URI.fromBytes(_ensureValidURI(url.strip()))
  File "/usr/lib/python3.9/site-packages/twisted/web/_newclient.py", line 634, in _ensureValidURI
    if _VALID_URI.match(uri):
builtins.TypeError: cannot use a bytes pattern on a string-like object

But, let me work with this and see if I can get it running and I should be good at least for this situation.

Column01 commented 2 years ago

Mark2's jar system is no longer supported at this time, it needs some serious updating and is not on my list of things to fix at this time. Mark2 will generate a default configuration file in .config/mark2 for use if none is present in the server directory. You will need to add a mark2.properties file to the server directory and edit the value to point to the server jar you wish to use (see the samples directory for an example mark2.properties to place in a server directory). It doesn't need to be the full file that mark2 config generates, it only needs changes you want to make inside it (for example changing the jar path or memory limits).

Column01 commented 2 years ago

Also, this implementation is actually going to be changed when #133 gets implemented and it might fix this particular issue

Tellik commented 2 years ago

Ah, got it. I'll ignore that option then.

Finished setting things up and it worked with getting a server running.

One issue I did run into was in the config file for possible speed-ups, I had an option set "G1NewSizePercent" that is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions. However, I had the config file line uncommented and active for "java.cli.XX.UnlockExperimentalVMOptions=true". My guess is that those don't work, but I was able to add my testing java launch arguments to the prepend config file part and they were all used correctly.

Other than that, everything's really clean and good. Thanks for your assistance.

Column01 commented 2 years ago

The JVM arguments should be placed in order of how they are laid out in the config. So if you put java.cli.XX.UnlockExperimentalVMOptions=true at the top it would load it first which enables the other options you wanted to use. Although prepend does work too 😄

Gonna close this, if you need any other help, join the discord server and post a message in the support channel

Tellik commented 2 years ago

Ahhh, that makes more sense then. No worries, everything is resolved. Thank you again.

Column01 commented 2 years ago

Ended up updating the jar system to work again for vanilla jars. Figured it was useful and I was motivated... not gonna get into how much of a nightmare it actually was...