Skip to content

Add an example for --server argument in the dedicated server tutorial #10789

@rezafbrn

Description

@rezafbrn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:manualIssues and PRs related to the Manual/Tutorials section of the documentationenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions