| OLD | NEW |
| 1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 #library("total:runner"); | 6 #library("total:runner"); |
| 7 | 7 |
| 8 typedef void ExitCallback(int status, String exitString); | 8 typedef void ExitCallback(int status, String exitString); |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| 11 String SERVER_EXEC_PATH = './TotalServer.dart'; | 11 String SERVER_EXEC_PATH = './TotalServer.dart'; |
| 12 String RESTART = "GRACEFUL RESTART!!"; | 12 String RESTART = "GRACEFUL RESTART!!"; |
| 13 String EXIT = "GRACEFUL EXIT!!"; | 13 String EXIT = "GRACEFUL EXIT!!"; |
| 14 | 14 |
| 15 void keepServerRunning(int status, ServerRunner runner) { | 15 void keepServerRunning(int status, ServerRunner runner) { |
| 16 switch (runner.lastExitString) { | 16 switch (runner.lastExitString) { |
| 17 case RESTART: | 17 case RESTART: |
| 18 runner.lastExitString = ''; |
| 18 runner.run(keepServerRunning); | 19 runner.run(keepServerRunning); |
| 19 break; | 20 break; |
| 20 case EXIT: | 21 case EXIT: |
| 21 break; | 22 break; |
| 22 default: | 23 default: |
| 23 print("ERROR: exiting due to unknown condition. Exit status: $status." | 24 print("ERROR: exiting due to unknown condition. Exit status: $status." |
| 24 + " Exit string: '${runner.lastExitString}'"); | 25 + " Exit string: '${runner.lastExitString}'"); |
| 25 break; | 26 break; |
| 26 } | 27 } |
| 27 } | 28 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 if (line.contains(e, 0)) { | 89 if (line.contains(e, 0)) { |
| 89 lastExitString = e; | 90 lastExitString = e; |
| 90 return true; | 91 return true; |
| 91 } else { | 92 } else { |
| 92 return false; | 93 return false; |
| 93 } | 94 } |
| 94 }); | 95 }); |
| 95 } | 96 } |
| 96 | 97 |
| 97 } | 98 } |
| OLD | NEW |