Skip to content
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

Add option to restart Application on Asset change #2626

Open
1 task done
MarjanDB opened this issue Jul 3, 2024 · 6 comments
Open
1 task done

Add option to restart Application on Asset change #2626

MarjanDB opened this issue Jul 3, 2024 · 6 comments
Labels

Comments

@MarjanDB
Copy link

MarjanDB commented Jul 3, 2024

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

The problem I'm facing is similar to these two already existing closed issues:

I have definition / configuration files that are read by the application during its bootstrap phase which configures certain features of the application. Using the watchAssets option as described here does update the files in the distribution folder when they're changed, but since they're only picked up during the application bootstrap phase, this effectively does nothing (as the application requires a restart for the changes to take effect). I have to resort to manually restarting the server, or if the application is running inside a mounted docker container, changing a random bit of code so that nest start --watch restarts the application.

Describe the solution you'd like

Changing the behavior of watchAssets to do this would be nice, but I understand that this sort of change is not something others developers may want.

Since this is the case, introducing a new option to handle the restart could be a viable solution to the problem that does not break existing workflows.

An option along the lines of restartApplicationOnChange could be added wherever watchAssets is currently possible to be specified. When this option is set to true, the application will restart if the asset is changed.

This would also give the developer the ability to more finely control when the application requires a restart should they need it.

Something that would fall out with this change would be the inconsistency of "watch" options :

  • --watch will restart on code changes,
  • watchAssets will not restart on asset changes,
  • but specifying restartApplicationOnChange alongside watchAssets will restart on asset changes

Perhaps restartApplicationOnChange could be considered as being false by default, and later changed to true by default with a major release. This would resolve the inconsistency of "watch" options while still providing a method for developers to go back to using their old workflows (no restarts on asset changes).

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

Already explained in the first section, but in short:
I have configuration files that are read during bootstrap and only during bootstrap. A restart of the application is required in order to actually apply the changes that were made.

@micalevisk
Copy link
Member

doesn't typing rs (with compilerOptions.manualRestart:true) resolves this?

@MarjanDB
Copy link
Author

MarjanDB commented Jul 3, 2024

@micalevisk

doesn't typing rs (with compilerOptions.manualRestart:true) resolves this?

If running on the local machine, yes (with the caveat that you have to manually do it).
Running it in a docker container where the source files are mounted: no (at least I'm not familiar with any method of doing so).

@matutetandil
Copy link

+1
I need this feature since I'm developing a graphql gateway and the schema.graphql can change so I'd like my server to restart automatically.

@tbhaxor
Copy link

tbhaxor commented Sep 7, 2024

Or better we should use --watchAssets an array of files to watch, instead of boolean field.

@dani-filipovic
Copy link

+1

1 similar comment
@ntngel1
Copy link

ntngel1 commented Nov 6, 2024

+1

@nestjs nestjs locked and limited conversation to collaborators Nov 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants