altmp / altv-issues

Issues and roadmap for alt:V project
93 stars 16 forks source link

resourceStop event not working on Linux server #2280

Open PainedPsyche opened 4 months ago

PainedPsyche commented 4 months ago

Description of the problem

When pressing ctrl+C in the server console, it seems like resourceStop event is not emitted.

Reproduction steps

import alt from 'alt-server';

console.log('resourceStop handler loaded')

alt.on('resourceStop', async function() {
    console.log('resource stopped');
    await alt.Utils.wait(5000)
});

Start the server and then hit Ctrl+C to stop it.

Expected behaviour

Both resourceStop handler loaded' and resource stopped messages will appear in the server console log.

Additional context

No response

Operating system

Rocky Linux 9.3 (Blue Onyx)

Version

v16.0.0-dev.389

Crashdump ID

No response

Confirmation of issue's presence

BluePeer commented 4 months ago

it is default that you have issues with async code inside a sync system this require sync code other the resource is stopped after call the stopevent is ended and the resource terminated before the async code is fully executed

PainedPsyche commented 4 months ago

it is default that you have issues with async code inside a sync system this require sync code other the resource is stopped after call the stopevent is ended and the resource terminated before the async code is fully executed

Changing it to sync code like this:

import alt from 'alt-server';

console.log('resourceStop handler loaded')

alt.on('resourceStop', function() {
    console.log('resource stopped');
});

Results in the exact same behavior: the message inside the event is not displayed.

BluePeer commented 4 months ago

ah yeah sorry i missed some other points sorry strg+C does not shutdown the server, it kills the server to shutdown a server and trigger the stop event you need to use quit strg+c does not show stopping resource xxxx inside console

PainedPsyche commented 4 months ago

trigger the stop event you need to use quit strg+c does not show stopping resource xxxx inside console

This is kinda offtopic, but how do you do that? I mean "use quit".

The server does not seem to have an interactive shell. Is there any documentation listing commands you can use on the server and how to actually input them?

xxshady commented 4 months ago

@BluePeer resourceStop supports promise, it works on windows, and ctrl+c also should work with it

xxshady commented 4 months ago

can also be related: https://github.com/altmp/altv-issues/issues/1863

BluePeer commented 4 months ago

trigger the stop event you need to use quit strg+c does not show stopping resource xxxx inside console

This is kinda offtopic, but how do you do that? I mean "use quit".

The server does not seem to have an interactive shell. Is there any documentation listing commands you can use on the server and how to actually input them?

https://docs.altv.mp/articles/commandlineargs.html#server-commands quit is also a command and some others

remember we are able to create custom ones https://docs.altv.mp/js/api/alt-server.IServerEvent.html#_altmp_altv_types_alt_server_IServerEvent_consoleCommand if there is no way to enter, then this makes no sense ;)

can also be related: #1863

the strg+c instant exit is since 12 <-> 14 so can be related but it is older then this found. i can't find it currently (idk if that talk is inside a issue or discord)