Open TehseenNawaz opened 5 years ago
PartitionId will always remain same during life time of a service. You will need to delete and create the app again if you want paritionid to change. What is your use case ?
I am using Service fabric guestExecutable service. Which on start execute a script.
So my use case is that if a service goes into an error or warning state and i will restart this service. So it will need to execute the script again. And restart mechanism restart the actual service not only the instance of that service. Is this possible or not?
please clarify that RemoveReplicaAsync() method only restart the instance or it restart the actual service also. According to my knowledge it only restart the instance of service.
Thanks
restart a service
is different from restart a replica of a service
?
Do you mean restart a service
is == restart all replicas of a service
?PartitionId
of the replica ?RemovReplicaAsync
removes that replica. However, you have specified that you want N
replicas in your ApplicationManifest.xml, but now we have N-1
replica. So, SF will create another instance with new instance id. So, it "looks" like we have restarted the replica.
You may want RestartReplicaAsync if you want to restart replica. It should be faster as well.
Thanks ashishnegi. Actually, I don't care even if the partition ID changes after the restart. I just want the service to be restarted such that the scripts in SetupEntryPoint of my service should execute which is not happening in case, I restart even all the replicas of a service. The said scripts get executed when the service initializes for the first time, I want to have the same behavior for the restart. I do know that I can achieve this by simply deleting and restarting my services but I just wanted to know any automated way to achieve this provided by the platform.
Can you have only one script combined of your current : setupentrypoint and mainentry point scripts ?
@TehseenNawaz SetupEntryPoint is for setup porposes, which is not called on restart because restart of service will happen on the same node itself.
It seems your setup is not actually setup work but part of main code that should execute always.
The script that i want to be execute on Restart is not in SetupEntryPoint it was the part of EntryPoint. You can see it below. RunServer.bat is script name.
So share your thoughts , what is the recommended place where i can put this script and it will execute on Restart?
@TehseenNawaz EntryPoint
's RunServer.bat
should execute on every restart. Is this not what you are seeing ? Can you try login into the node after RestartReplicaAsync
call and see if RunServer.bat
is running or not ?
Earlier, you said :
I just want the service to be restarted such that the scripts in *SetupEntryPoint* of my service
should execute which is not happening in case, I restart even all the replicas of a service.
I think there is some confusion.
Sorry the script was in entry point. But it did't execute on restart. I restart the Stateless GuestExe service by using RemoveReplicaAsync() method. So every time it spin up a new instance but it did not execute script.
Hi,
FabricClient.ServiceManager.RemoveReplicaAsync(NodeName, PartitionId, ReplicaOrInstanceId); //stateless FabricClient.ServiceManager.RestartReplicaAsync(); //statefull
The above lines of code, Restart a replica of statefull service or instance of stateless service. But it does not restart the actual service. The replica or instance Id of a service will be changed after restart but the partitionID remain same. Is there is any way to restart a service?