| | |
| | | // 4.4 åå»ºææ´æ°å®ä¾ |
| | | if (_instanceManager.InstanceExists(device.DeviceCode)) |
| | | { |
| | | _logger.LogInformation("å®ä¾ {DeviceCode} å·²åå¨ï¼è·³è¿å建", device.DeviceCode); |
| | | // å®ä¾å·²åå¨ï¼æ´æ°é
ç½® |
| | | var instance = _instanceManager.GetInstance(device.DeviceCode); |
| | | if (instance != null) |
| | | { |
| | | var oldState = instance.GetState(); |
| | | var wasRunning = oldState.Status == InstanceStatus.Running; |
| | | |
| | | // 忢æ§å®ä¾ |
| | | await _instanceManager.StopInstanceAsync(device.DeviceCode); |
| | | |
| | | // å 餿§å®ä¾ï¼ä¿çé
ç½®ï¼ |
| | | await _instanceManager.DeleteInstanceAsync(device.DeviceCode, deleteConfig: false); |
| | | |
| | | // éæ°å建å®ä¾ |
| | | var newInstance = await _instanceManager.CreateInstanceAsync(config); |
| | | if (wasRunning) |
| | | { |
| | | await _instanceManager.StartInstanceAsync(device.DeviceCode); |
| | | } |
| | | _logger.LogInformation("å·²æ´æ°å®ä¾ {DeviceCode} (端å£:{Port})", device.DeviceCode, device.DevicePort); |
| | | } |
| | | } |
| | | else |
| | | { |