這是一個與worker角色託管的VM有關的問題。我有一個簡單的工作者角色,它跨越了一個進程。產生的過程是32位編譯的TCPServer應用程序。工作者角色在其中定義了一個端點,TCP服務器被綁定到工作者角色的終點。所以當我連接到我的工作者角色端點,併發送一些東西時,TCPserver會收到它,處理它返回一些東西。因此,這裏暴露於外部世界的工作者角色的端點在內部連接到TCP服務器。Azure VM意外重啓
string port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[""TCPsocket].IPEndpoint.Port.ToString();
var myProcess = new Process()
{
StartInfo = new ProcessStartInfo(Path.Combine(localstorage.RootPath, "TCPServer.exe"))
{
CreateNoWindow = true,
UseShellExecute = true,
WorkingDirectory = localstorage.RootPath,
Arguments = port
}
};
這是工作的罰款。但突然停止響應。當我登錄入口時,VM角色自動重啓。但它從未成功。它顯示Role Initializing..
狀態。手動停止並開始也不會工作。我重新部署了相同的程序包,沒有對代碼進行任何更改。這次部署本身失敗。
Warning: All role instances have stopped - There was no endpoint listening at https://management.core.windows.net/<SubscriptionID>/services/hostedservices/TCPServer/deploymentslots/Production that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
但一段時間後,我再次試圖部署後,它工作得很好。 誰能告訴我會是什麼問題?
更新:
public override void Run()
{
Trace.WriteLine("RasterWorker entry point called", "Information");
string configVal = RoleEnvironment.GetConfigurationSettingValue("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString");
CloudStorageAccount _storageAccount = null;
_storageAccount = CloudStorageAccount.Parse(configVal); // accepts storage cridentials and create storage account
var localstorage = RoleEnvironment.GetLocalResource("MyLocalStorage");
CloudBlobClient _blobClient = _storageAccount.CreateCloudBlobClient();
bool flag = false;
while (true)
{
Thread.Sleep(30000);
if (!flag)
{
if (File.Exists(Path.Combine(localstorage.RootPath, "test.ppm")))
{
CloudBlobContainer _blobContainer = _blobClient.GetContainerReference("reports");
CloudBlob _blob = _blobContainer.GetBlobReference("test.ppm");
_blob.UploadFile(Path.Combine(localstorage.RootPath, "test.ppm"));
Trace.WriteLine("Copy to blob done!!!!!!!", "Information");
flag = true;
}
else
{
Trace.WriteLine("Copy Failed-> File doesnt exist!!!!!!!", "Information");
}
}
Trace.WriteLine("Working", "Information");
}
}
我同意你的觀點。正如你所說,run方法永遠不會返回,因爲它有一個無限循環。我的行爲和你上面講的一樣。只有變化的是,我在'OnStart()'方法中開始我的過程。然後進入'運行()'。 –
你可以發佈你在Run方法中的代碼嗎? –
請參閱使用'Run()'方法更新的問題 –