-
-
Couldn't load subscription status.
- Fork 496
Modernized start, stop and restart commands
#4023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
We should probably add an argument ensure to restartResource (defaulting to false)?
The reason I don't suggest adding a separate API function for this (e.g: ensureResource), is because we'd need to repeat the arguments and associated logic for those anyway.
Edit: since you'd need to upgrade restartResource to the new arg parser anyway, the code would actually end up being reasonably sized; having an additional function such as ensureResource wouldn't be so bad.
So, it's up to you and whatever others think is best.
We should probably add an argument
ensureto restartResource (defaulting to false)?
Why do you need that when you can get the state of your resource before calling? A new argument doesn't improve readability
I suggest to remove a new 'ensure' command and just change 'restart' behavior. Current 'restart' behavior is disappointing.
I suggest to remove a new 'ensure' command and just change 'restart' behavior. Current 'restart' behavior is disappointing.
I agree with this too, but would we want to change the behaviour of restartResource function by default?
Technically that isn't backwards compatible, someone may rely on the fact a resource must be running when this function or command is called.
Nonetheless, it would be much better behaviour for the restart command and function to start resources that aren't running, instead of doing nothing/returning false.
Changing restart command functionality to support starting a resource even if it is stopped does not make sense, as the name implies a stop then a start, not just a start.
New ensure command makes sense, it's practical. I support it.
We should probably add an argument
ensureto restartResource (defaulting to false)?The reason I don't suggest adding a separate API function for this (e.g:
ensureResource), is because we'd need to repeat the arguments and associated logic for those anyway.Edit: since you'd need to upgrade
restartResourceto the new arg parser anyway, the code would actually end up being reasonably sized; having an additional function such asensureResourcewouldn't be so bad.So, it's up to you and whatever others think is best.
I guess we can discuss that later, but in a separate issue or pull request, this one is focused solely on improving the commands
Changing restart command functionality to support starting a resource even if it is stopped does not make sense, as the name implies a stop then a start, not just a start.
New ensure command makes sense, it's practical. I support it.
I want to introduce the new command because restart is well known and widely used, and I don't want to change that. ensure is also common in other game engine like multiplayer modifications, so it should feel familiar to developers interested in modern stuff
I want to introduce the new command because
restartis well known and widely used, and I don't want to change that.ensureis also common in other game engine like multiplayer modifications, so it should feel familiar to developers interested in modern stuff
As far as I know, only FiveM has the ensure command. The suggested restart behavior is much more common in Linux, e.g. the service command works in this way. I expect that the restart command starts stopped services and resources.
I can't imagine that somebody wouldn't expect to start a resource using the restart command.
I see no reason to have two commands with almost identical behavior instead of using one command with expected name.
Technically that isn't backwards compatible, someone may rely on the fact a resource must be running when this function or command is called.
I can't imagine a scenario when you need that. I would suggest writing a function that implements the old behavior if someone needs that. A failed restart commad forced me to use start in all my cases.
blow1d
commented
May 8, 2025
Up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, gj
blow1d
commented
Jun 1, 2025
This should have been merged a long time ago, pr dessa is very economical in some factors
I'm okay with renaming the ensure command to restart if it matters in merging the pull request.
Good job 🥳🤙🏻
I think it might be better to integrate the behavior of ensure into the existing restart command.
Users who want the behavior of ensure will likely use restart instinctively anyway.
If a script isn't running, and someone uses restart, it's usually because they want it to start so letting restart handle both running and stopped resources could reduce confusion and eliminate the need to introduce a new command
Kinimel
commented
Jul 31, 2025
GG Good job
start, stop, restart and new ensure command (削除ここまで)start, stop and restart commands (追記ここまで)
I'm okay with renaming the
ensurecommand torestartif it matters in merging the pull request.
Done. Now, the restart command is more Linux like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well.
This will benefit everyone
Uh oh!
There was an error while loading. Please reload this page.
Modernized
start,stop,restartcommands which now also support directories, see the examples below, and from now on, therestartcommand not just restarts the already running resources specified as parameters, but also starts the stopped ones.Closes #2549.