-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Your Godot version:
v4.4
Issue description:
The documentation for the dedicated server contains an example of the following code to differentiate between normal and dedicated server use.
if "--server" in OS.get_cmdline_user_args():
# Run your server startup code here...
#
# Using this check, you can start a dedicated server by running
# a Godot binary (editor or export template) with the `--server`
# command-line argument.
pass
However, during my tests the code does not work. Here is how I tested them.
Godot script
func _ready():
print("Starting game.")
print(OS.get_cmdline_args())
print(OS.get_cmdline_user_args())
if "--server" in OS.get_cmdline_args():
print("Started in server mode.")
Output in ubuntu 22 LTS headless
$ ./test.x86_64 --server --headless
Godot Engine v4.4.stable.official.4c311cbee - https://godotengine.org
Starting game.
["--server"]
[]
Started in server mode.
So in my tests I need to use OS.get_cmdline_args() to catch the --server argument. If I follow the documentation for dedicated servers, I get an empty array. As a new Godot user, I'm not sure if this is a bug in Godot, outdated documentation, or maybe just in my particular environment.
URL to the documentation page:
https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_dedicated_servers.html
(maybe relevant) https://docs.godotengine.org/en/stable/classes/class_os.html