我有兩個飛鏢應用程序可以在亞馬遜(AWS Ubuntu的),它運行的是:如何檢測飛鏢VM崩潰的原因
- 自託管的HTTP API
- 工人來處理一個定時器 後臺任務
這兩個應用程序都使用PostgreSQL。他們偶爾會崩潰,除了試圖找到根本原因之外,我還實施了一個超級用戶腳本,它只是檢測這兩個主要應用程序是否正在運行並根據需要重新啓動它們。
現在我需要解決的問題是監督腳本崩潰或虛擬機崩潰。它每隔幾天發生一次。
我不認爲這是內存泄漏,因爲如果我把投票率從10秒提高到更常(1納秒),它在Dart天文臺正確顯示它耗盡了30MB,然後垃圾收集並啓動低內存使用率,並保持騎自行車。
我不會認爲這是一個未捕獲的異常,因爲無限循環完全封閉在try/catch中。
我不知道還有什麼可嘗試的。是否有虛擬機轉儲文件,可以檢查虛擬機是否真的崩潰?有沒有其他技術來調試根本原因? Dart不夠穩定,無法一次運行幾天的應用程序?
這是主管腳本代碼的主要部分:
///never ending function checks the state of the other processes
Future pulse() async {
while (true) {
sleep(new Duration(milliseconds: 100)); //DEBUG - was seconds:10
try {
//detect restart (as signaled from existence of restart.txt)
File f_restart = new File('restart.txt');
if (await f_restart.exists()) {
log("supervisor: restart detected");
await f_restart.delete();
await endBoth();
sleep(new Duration(seconds: 10));
}
//if restarting or either proc crashed, restart it
bool apiAlive = await isRunning('api_alive.txt', 3);
if (!apiAlive) await startApi();
bool workerAlive = await isRunning('worker_alive.txt', 8);
if (!workerAlive) await startWorker();
//if it's time to send mail, run that process
if (utcNow().isAfter(_nextMailUtc)) {
log("supervisor: starting sendmail");
Process.start('dart', [rootPath() + '/sendmail.dart'], workingDirectory: rootPath());
_nextMailUtc = utcNow().add(_mailInterval);
}
} catch (ex) {}
}
}
您沒有得到任何包含有關崩潰信息的控制檯輸出?您可以在AWS外部複製(在本地機器的外殼中)嗎? –
我試圖在本地運行大大增加時間重現,但不能。主管腳本將stdout寫入文件,該文件沒有任何內容超出了我明確寫的範圍。就好像它正常退出一樣。 –
我假設你也將stderr重定向到文件中? –