| Index: samples/total/src/TotalRunner.dart
|
| diff --git a/samples/total/src/TotalRunner.dart b/samples/total/src/TotalRunner.dart
|
| index c05c9b0962f598d5ef0cac246ffd14cfb9a95636..4db1892c9fb0a4b2126176a7d60923deea4de7f7 100755
|
| --- a/samples/total/src/TotalRunner.dart
|
| +++ b/samples/total/src/TotalRunner.dart
|
| @@ -9,39 +9,34 @@ typedef void ExitCallback(int status, String exitString);
|
|
|
| void main() {
|
| String SERVER_EXEC_PATH = './TotalServer.dart';
|
| - String RESTART = "GRACEFUL RESTART!!";
|
| - String EXIT = "GRACEFUL EXIT!!";
|
| + final int RESTART_STATUS = 42;
|
| + final int EXIT_STATUS = 0;
|
|
|
| void keepServerRunning(int status, ServerRunner runner) {
|
| - switch (runner.lastExitString) {
|
| - case RESTART:
|
| - runner.lastExitString = '';
|
| + switch (status) {
|
| + case RESTART_STATUS:
|
| runner.run(keepServerRunning);
|
| break;
|
| - case EXIT:
|
| + case EXIT_STATUS:
|
| break;
|
| default:
|
| - print("ERROR: exiting due to unknown condition. Exit status: $status."
|
| - + " Exit string: '${runner.lastExitString}'");
|
| + print("ERROR: exiting due to unknown condition. Exit status: $status.");
|
| break;
|
| }
|
| }
|
|
|
| - new ServerRunner(SERVER_EXEC_PATH, [RESTART, EXIT]).run(keepServerRunning);
|
| + new ServerRunner(SERVER_EXEC_PATH).run(keepServerRunning);
|
| }
|
|
|
| class ServerRunner {
|
| - List<String> _exitStrings;
|
| String _serverMain;
|
|
|
| - String lastExitString;
|
| -
|
| // TODO: Release or Debug? We should be able to find automatically
|
| static final DART_EXEC_PATH = '../../../runtime/out/Release_ia32/dart_bin';
|
| static final CR = 0x0d;
|
| static final LF = 0x0a;
|
|
|
| - ServerRunner(String this._serverMain, List<String> this._exitStrings);
|
| + ServerRunner(String this._serverMain);
|
|
|
| void run(ExitCallback exitCallback) {
|
| Process dart = new Process(DART_EXEC_PATH, [_serverMain]);
|
| @@ -72,21 +67,8 @@ class ServerRunner {
|
| readSoFar.clear();
|
| if (line.length != 0) {
|
| print(line);
|
| - _updateLastExitString(line);
|
| }
|
| }
|
| });
|
| }
|
| -
|
| - void _updateLastExitString(String line) {
|
| - _exitStrings.some((String e) {
|
| - if (line.contains(e, 0)) {
|
| - lastExitString = e;
|
| - return true;
|
| - } else {
|
| - return false;
|
| - }
|
| - });
|
| - }
|
| -
|
| }
|
|
|