Repository: oppia/oppia

Issue:
Create Command Line Argument for No Automatic Restart
Due to the way the App Engine checks for changed files on MacOS, running the server sends the CPU into very high usage. For more details, see this link: https://medium.com/lumapps-engineering/appengine-on-macos-is-a-cpu-hog-heres-how-to-solve-this-problem-with-another-python-native-9f2a6dc5c960

As a quick workaround, it would be nice to have a flag to turn off the auto-restart-on-changed-file feature. There is a flag mentioned in the link above that allows you to turn it off in App Engine. This would allow me to run `python -m scripts.start --no-auto-restart`, or something similar, to run the server without my CPU running wild.
Create Command Line Argument for No Automatic Restart
Due to the way the App Engine checks for changed files on MacOS, running the server sends the CPU into very high usage. For more details, see this link: https://medium.com/lumapps-engineering/appengine-on-macos-is-a-cpu-hog-heres-how-to-solve-this-problem-with-another-python-native-9f2a6dc5c960

As a quick workaround, it would be nice to have a flag to turn off the auto-restart-on-changed-file feature. There is a flag mentioned in the link above that allows you to turn it off in App Engine. This would allow me to run `python -m scripts.start --no-auto-restart`, or something similar, to run the server without my CPU running wild.


Discussion:
@tyleri, since this isn't a trivial impact, can you work on this? thanks!
@kevinlee12 Yeah, thanks for assigning it to me! @seanlip actually already asked me to work on it, but I forgot to claim it. Will work on this.
ah, thanks!
@tyleri, since this isn't a trivial impact, can you work on this? thanks!
@kevinlee12 Yeah, thanks for assigning it to me! @seanlip actually already asked me to work on it, but I forgot to claim it. Will work on this.
ah, thanks!

Resolving patch:
diff --git a/scripts/start.py b/scripts/start.py
--- a/scripts/start.py
+++ b/scripts/start.py
@@ -60,6 +60,12 @@
     '--no_browser',
     help='optional; if specified, does not open a browser.',
     action='store_true')
+_PARSER.add_argument(
+    '--no_auto_restart',
+    help=(
+        'optional; if specified, does not automatically restart when files are '
+        'changed.'),
+    action='store_true')
 
 PORT_NUMBER_FOR_GAE_SERVER = 8181
 
@@ -92,6 +98,8 @@ def main(args=None):
         '' if parsed_args.save_datastore else '--clear_datastore=true')
     enable_console_arg = (
         '--enable_console=true' if parsed_args.enable_console else '')
+    no_auto_restart = (
+        '--automatic_restart=no' if parsed_args.no_auto_restart else '')
 
     if parsed_args.prod_env:
         constants_env_variable = '"DEV_MODE": false'
@@ -139,10 +147,10 @@ def main(args=None):
 
     python_utils.PRINT('Starting GAE development server')
     background_processes.append(subprocess.Popen(
-        'python %s/dev_appserver.py %s %s --admin_host 0.0.0.0 --admin_port '
+        'python %s/dev_appserver.py %s %s %s --admin_host 0.0.0.0 --admin_port '
         '8000 --host 0.0.0.0 --port %s --skip_sdk_update_check true %s' % (
             common.GOOGLE_APP_ENGINE_HOME, clear_datastore_arg,
-            enable_console_arg,
+            enable_console_arg, no_auto_restart,
             python_utils.UNICODE(PORT_NUMBER_FOR_GAE_SERVER),
             app_yaml_filepath), shell=True))
 


Test patch: