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 support for restarting services from the dashboard #295

Closed
davidfowl opened this issue Oct 15, 2023 · 23 comments · Fixed by #5538
Closed

Add support for restarting services from the dashboard #295

davidfowl opened this issue Oct 15, 2023 · 23 comments · Fixed by #5538
Assignees
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-dashboard
Milestone

Comments

@davidfowl
Copy link
Member

In building apps with the aspire, I'm often using the dashboard as a debugging aid, when a process dies it pretty disruptive to have to restart the entire orchestration project in order to reproduce an issue. It would be great to have the ability to restart a process from the dashboard.

@dbreshears dbreshears added this to the some time after preview milestone Oct 16, 2023
@danmoseley
Copy link
Member

@karolz-ms can you evaluate whether this is doable for preview? not critical for preview but is a signficant pain point.

@karolz-ms karolz-ms self-assigned this Oct 17, 2023
@karolz-ms
Copy link
Member

karolz-ms commented Oct 18, 2023

I believe the change can be done solely in dashboard view model code. Namely, to restart a service, the model code should:

  1. Fetch the corresponding Executable from DCP
  2. Memorize the Executable.Spec and annotations.
  3. Delete the Executable
  4. Re-create the Executable with the same name, Spec and annotations.

I cannot think of any change on the DCP side that would be required for the above to work as desired, but if we discover something missing, by all means open an issue on the DCP repo.

The same technique should also work for restarting Containers.

@dbreshears dbreshears removed this from the some time after preview milestone Oct 18, 2023
@dbreshears
Copy link
Contributor

Cleared milestone for dashboard triage to see if it fits

@smitpatel
Copy link
Member

@karolz-ms - Do we need to do anything wrt service/endpoint when deleting/re-creating the service? Would the same work for container/executable?

@dbreshears dbreshears added this to the preview-2 weeks milestone Oct 18, 2023
@karolz-ms
Copy link
Member

@smitpatel no we don't but we need to make sure that annotations are preserved on the Executable/ExecutableReplicaSet. And the same procedure should also work for Containers. I am going to update my previous comment with this information.

@tlmii tlmii modified the milestones: preview-2 weeks, some time after preview Oct 27, 2023
@tlmii tlmii removed their assignment Oct 27, 2023
@smitpatel smitpatel self-assigned this Nov 3, 2023
@danmoseley danmoseley removed this from the needs milestone (for GA) milestone Nov 13, 2023
@HClausing
Copy link

In building apps with the aspire, I'm often using the dashboard as a debugging aid, when a process dies it pretty disruptive to have to restart the entire orchestration project in order to reproduce an issue. It would be great to have the ability to restart a process from the dashboard.

Just an idea for the future: On some scenarios this restart action can require an authorized user, and optionally with roles or policies requirements.

@aL3891
Copy link

aL3891 commented Nov 17, 2023

Was looking to add a request for this as well, both in the case where a service has died (obv not due to an error on my part) and when ive made a change in the running app and need to restart it.
i guess optionally it could also monitor the source for a service and restart it? (assuming hot reload doesnt just work as is)

@davidfowl
Copy link
Member Author

Using dotnet watch handles the latter case on command line and VS does the same when you use ctrl+f5. You can also hot reload when you hit F5

@aL3891
Copy link

aL3891 commented Nov 17, 2023

So dotnet watch is transitive? that's nice! i tried it now though and got errors like this in the logs

dotnet watch 🚀 Started
C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.GenerateAssemblyInfo.targets(199,5): error MSB3713: The file "obj\Debug\net8.0\LoginserverDb.AssemblyInfo.cs" could not be created. The process cannot access the file 'C:\Funrock\mma_backend2\LoginserverDb\obj\Debug\net8.0\LoginserverDb.AssemblyInfo.cs' because it is being used by another process. [C:\Funrock\mma_backend2\LoginserverDb\LoginserverDb.csproj]

and 

CSC : error CS2012: Cannot open 'C:\Funrock\mma_backend2\MMA.ServiceDefaults\obj\Debug\net8.0\MMA.ServiceDefaults.dll' for writing -- 'The process cannot access the file 'C:\Funrock\mma_backend2\MMA.ServiceDefaults\obj\Debug\net8.0\MMA.ServiceDefaults.dll' because it is being used by another process.' [C:\Funrock\mma_backend2\MMA.ServiceDefaults\MMA.ServiceDefaults.csproj]
C:\Program Files\dotnet\sdk\8.0.100\Microsoft.Common.CurrentVersion.targets(4734,5): warning MSB3026: Could not copy "obj\Debug\net8.0\Common.dll" to "bin\Debug\net8.0\Common.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\Funrock\mma_backend2\Common\obj\Debug\net8.0\Common.dll' because it is being used by another process.  [C:\Funrock\mma_backend2\Common\Common.csproj::TargetFramework=net8.0]

Starting normaly without watch works for the same solution
(This is from the services themselves, the app host starts normally)

@jooooel
Copy link

jooooel commented Nov 19, 2023

I haven't had the chance to play around with Aspire yet, but this would be great! It's also part of the main big thing I think Tye was missing: being able to start/stop/restart services on demand: dotnet/tye#876

dotnet watch is nice but has two drawbacks as I see it

  1. In large solutions, it's much faster to restart things if there are changes in core libraries that many projects depend on
  2. I rarely want to start our entire set of applications, but just a core set. Then, depending on what I'm working on I often want to start up another service (projects, containers, etc) as well.

It would be great if there was a way of communicating with the host via a CLI/API to do these things (kind of like what you can do with docker compose, which is what I'm mainly using now). That would also imply that the host only defines the configuration, and that you can toggle things on and off during the lifetime of the host.

And by the way, I'm really happy that Tye got a revival in Aspire! It has so much potential for the inner dev loop, so I'm glad it did 😊

@davidfowl
Copy link
Member Author

It would be great to get this in for the next preview based on your prototype @tlmii

@aL3891
Copy link

aL3891 commented Nov 21, 2023

Perhaps that is what you've already done but one option would be to be able to start/restart services in watch mode from the dashboard? Maybe that could also be configured in the startup profile? So i can have a profile called "debug flimflam" that is set to Start service A normally, watch service B, ignore service C

@DamianEdwards
Copy link
Member

@aL3891 that sounds like #303

@davidfowl
Copy link
Member Author

@drewnoakes This is something we want and I know you were looking at adding command support. This would be the first one.

@davidfowl davidfowl added this to the preview TBD (but in 8.0) milestone Jan 27, 2024
@drewnoakes drewnoakes self-assigned this Jan 27, 2024
@davidfowl
Copy link
Member Author

davidfowl commented Mar 30, 2024

Unfortunately restart isn't enough for that since the apphost won’t rebuild your code. If you’re in visual studio, you have to run without debugging to get a more incremental experience without hot reload.

@davidfowl davidfowl modified the milestones: Backlog, 8.1 May 15, 2024
@MadL1me
Copy link

MadL1me commented Jun 1, 2024

@davidfowl

I think not only restart, but replica count change from dashboard would be very helpful.

For example, we can start with ReplicaCount = 3 for service, but we can change it to "0" and "4", for example. This will insanely help with testing scenarios of failovers locally - test what happens if you just turn off the database, and than rescale it

In my head, this would like smth like this:

image_2024-06-02_00-06-29

This will also resolve issue #3095 - as one of the ways to perform "complete stop" of the service (or even restart, after some time, with specified replica count we want)

However, It seems easy to add this feature for .NET apps, but it's might be not so trivial for applications where nodes are required to be in state of consensus (any leader-election, multimaster or master-replica architecture) (for example Kafka or Postgres), because it might be required to add info to all brokers/servers about new added host.

UPD: Decided to move disscussion about replicas to dedicated issue

@davidfowl
Copy link
Member Author

I saw the issue you filed, but restart is what we’ll do first as it’s well understood and useful scenario.

@kvenkatrajan
Copy link
Member

FYI - @drewnoakes / @karolz-ms

@davidfowl
Copy link
Member Author

Fixed in #295

@github-actions github-actions bot locked and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-dashboard
Projects
None yet
Development

Successfully merging a pull request may close this issue.