#Is there a way to launch multiple instances with different parameters or environment variables?

12 messages · Page 1 of 1 (latest)

vagrant river
#

I'm trying to figure out if there's a way to launch 3 instances, (one server and two clients), by changing the arguments or environment variables passed to the multiple instances. Currently the 3 instances all launch the same way and I can't think of a way to differentiate them or coordinate which one becomes the server.

vagrant river
wild spruce
wild spruce
# vagrant river I'm trying to figure out if there's a way to launch 3 instances, (one server and...

I wonder when running those 3 instances they all get https://docs.godotengine.org/en/stable/classes/class_os.html#class-os-method-get-cmdline-args including the debug port? ... If so 1 has the lowest port num. Could they share this info? 🤔

vagrant river
#

I thought I wasn't seeing any of those additional debug args in this list. but I could double check when I get a chance

#

ah, perhaps I was using get_cmdline_user_args(). not sure. will check later on

wild spruce
#

I just tested this ... arguments are empty. But

printt('PID', OS.get_process_id())

It gets ugly but using (on MacOS)

printt('PID', OS.get_process_id())
var output = []
var exit_code = OS.execute("ps", ["-aef"], output)
var txt = output[0].split('\n')
for t in txt:
    var tt:String = t
    if tt.contains('Godot'):
        printt(t)

You can find the others PID and do your thing?

vagrant river
#

hmmmm

#

I think it would be better to (carefully) have all of them attempt to be a server, and if the port is in use, just switch to client mode.

#

Yeah, that actually works well. The only problem that remains is that there's an error printed to the log every time, which I'd have to ignore

#

E 0:00:01:0674 lobby.gd:116 @ _init_server(): Couldn't create an ENet host. <C++ Error> Condition "!host" is true. Returning: ERR_CANT_CREATE <C++ Source> modules/enet/enet_connection.cpp:318 @ _create() <Stack Trace> lobby.gd:116 @ _init_server() lobby.gd:97 @ initialize() lobby.gd:70 @ _ready()

#

wish there was a way to suppress this.