Git Product home page Git Product logo

Comments (8)

gekigek99 avatar gekigek99 commented on June 19, 2024

ok this seems cool!

just to know:
this does not work at all?

# listen for interrupt signal and issue stopEmptyMinecraftServer(true) before exiting
atexit.register(stopEmptyMinecraftServer, forceExec=True)

because for me it seemed to do the job..

from minecraft-server-hibernation.

lubocode avatar lubocode commented on June 19, 2024

Well, pressing ctrl + c on Windows doesn't do anything and pressing it on Linux (two presses needed to actually stop the script) the following happens:

Copyright (C) 2019-2020 gekigek99
v6.6 (Python)
visit my github page: https://github.com/gekigek99
12-Oct-20 16:48:43 *** listening for new clients to connect...
^CTraceback (most recent call last):
  File "minecraft-vanilla-server-hibernation.py", line 534, in <module>
    main()
  File "minecraft-vanilla-server-hibernation.py", line 145, in main
    clientSocket, clientAddress = listener.accept()        #blocking
  File "/usr/lib/python3.8/socket.py", line 292, in accept
    fd, addr = self._accept()
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/usr/lib/python3.8/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 1388, in _shutdown
    lock.acquire()
KeyboardInterrupt:

As such I tried to intercept the KeybordInterrupt with the signal listener and since a simple sys.exit(0) didn't work, I tried consolidating all spawned threads back into the main thread before exiting. Upon exit the functions registered with atexit.register for execution should still be executed. Although, as it is, it's not quite finished and still doesn't properly exit.

from minecraft-server-hibernation.

lubocode avatar lubocode commented on June 19, 2024

Will test if mc server gets shutdown on Windows when closing console and in Linux after two times ctrl + c.
If not, this is a bug. If yes, then enhancement status stays.

from minecraft-server-hibernation.

lubocode avatar lubocode commented on June 19, 2024

facepalm os.Exit(0) needs to be written in Uppercase...

from minecraft-server-hibernation.

gekigek99 avatar gekigek99 commented on June 19, 2024

facepalm os.Exit(0) needs to be written in Uppercase...

Wait... the uppercase thing is used in golang and I think it'correct to write sys.exit() in python

from minecraft-server-hibernation.

gekigek99 avatar gekigek99 commented on June 19, 2024

@lubocode since python is deprecated i will now close the issue... unless we want to solve this last one

I can create a branch from commit c5804b6 and re-release version 9.12 with this bug corrected

from minecraft-server-hibernation.

lubocode avatar lubocode commented on June 19, 2024

facepalm os.Exit(0) needs to be written in Uppercase...

Wait... the uppercase thing is used in golang and I think it'correct to write sys.exit() in python

... Oops.

@lubocode since python is deprecated i will now close the issue... unless we want to solve this last one

I can create a branch from commit c5804b6 and re-release version 9.12 with this bug corrected

Well, no. It's not exactly nice interrupt handling, but this is also not a bug, as the server is correctly shutting down upon exit. On Windows ctrl+c might not work, but closing the cmd window, in which the python script got started, also shuts down the server.

from minecraft-server-hibernation.

gekigek99 avatar gekigek99 commented on June 19, 2024

On Windows ctrl+c might not work, but closing the cmd window, in which the python script got started, also shuts down the server.

a okok fiuuu so now i'm in peace with myself. so i think I can move on.

from minecraft-server-hibernation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.