0
私はGoで小さなデスクトップWebアプリケーションを作成しています。このアプリケーションはローカルWebサーバーとして実行され、Chromeウィンドウは「アプリ」モードで生成されます。 Goプログラムはこの間にWebサーバーを継続して実行します。を使用してプロセス/プログラムが終了したかどうかを確認します。
ユーザーがこのChromeウィンドウを強制終了して、Webサーバーも閉じることができるようにする必要があります。
私は支援が必要な場所を示す以下のコメントを下さった。
package main
import (
"fmt"
"os/exec"
)
func main(){
// Setup the application and arguments.
cmd := "chrome"
// URL will be local webserver.
args := []string{"--user-data-dir=c:\\","--window-size=800,600","--app=http://www.google.com"}
// Start local webserver here.
// ...
// Prepare Chrome in app mode.
cmdExec := exec.Command(cmd, args...);
// Start Chrome asynchronously.
cmdExec.Start()
// Show to the user on the command line that the application is running.
fmt.Println("Application in progress! Please close webapp to close webserver!")
// Keep the webserver running, do web app things...
// Watch for that process we started earlier. If the user closes that Chrome window
// Then alert the user that the webserver is now closing down.
// This is where I need help!
watchForProcessThatWeStartedEarlierForClosure...()//????
// And we are done!
fmt.Println("Application exit!")
}
これは、Chromeのマルチプロセスアーキテクチャを考えるとややこしいかもしれません。 Webページがajax経由でサーバーに定期的にpingを送信し、pingが受信されない場合はタイムアウトする可能性がありますか? – nishantjr