Skip to content

Commit

Permalink
Fix oppia#5623 Move server launch to python (oppia#5657)
Browse files Browse the repository at this point in the history
* WIP audit model get seems difficult to call

* Remove start devserver from gulp

* Remove unneeded file

* Fix indent
  • Loading branch information
LanJosh authored and seanlip committed Sep 17, 2018
1 parent 27975a6 commit 162dfe9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 146 deletions.
59 changes: 6 additions & 53 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,19 @@
// limitations under the License.

/**
* @fileoverview We use this file to start GAE devserver, watch over third party
* @fileoverview We use this file to watch over third party
* related folders and files and to start rebuild process if needed. This file
* should be only used for the mentioned purposes until we devise a way to start
* devserver and watch folders from Python, then it should be removed.
* should be only used for the mentioned purposes until we devise a way
* to watch folders from Python, then it should be removed.
*/

var fs = require('fs');
var yargs = require('yargs');
var argv = yargs
.usage('Usage: $0 <command> [<options>]')
.command('start_devserver', 'start GAE development server',
.command('watch', 'watch files in nonprod mode',
function(yargs) {
argv = yargs
.usage('Usage: $0 start_devserver [--gae_devserver_path]' +
'[--clear_datastore] [--enable_sendmail]' +
'[--prod_env]')
.option('gae_devserver_path', {
describe: 'A path to app engine'
})
.option('enable_sendmail', {
describe: 'Whether to send emails'
})
.option('clear_datastore', {
describe: 'Whether to clear all data storage'
})
.option('prod_env', {
describe: 'Whether to run server in prod mode'
})
.demand(['gae_devserver_path'])
.usage('Usage: $0 watch')
.argv;
}).argv;

Expand All @@ -50,33 +34,11 @@ var concat = require('gulp-concat');
var childProcess = require('child_process');
var path = require('path');

var gulpStartGae = require('./scripts/gulp-start-gae-devserver');
var manifest = require('./manifest.json');

var thirdPartyCssFiles = path.join('third_party', 'static', '**', '*.css');
var thirdPartyJsFiles = path.join('third_party', 'static', '**', '*.js');

var isProdMode = argv.prod_env === 'True';
var gaeDevserverPath = argv.gae_devserver_path;
var params = {
admin_host: '0.0.0.0',
admin_port: 8000,
host: '0.0.0.0',
port: 8181,
skip_sdk_update_check: true
};
if (argv.clear_datastore) {
params.clear_datastore = true;
}

if (argv.enable_console) {
params.enable_console = true;
}

if (argv.enable_sendmail) {
params.enable_sendmail = argv.enable_sendmail;
}

// Check if there are enough commands/actions/tasks to run gulp.
var checkCommands = function(yargs, argv, numRequired) {
if (argv._.length < numRequired) {
Expand All @@ -89,11 +51,6 @@ var checkCommands = function(yargs, argv, numRequired) {
// There should atleast be minimum of one defined task.
checkCommands(yargs, argv, 1);

gulp.task('gulpStartGae', function() {
gulp.src('app.yaml')
.pipe(gulpStartGae(gaeDevserverPath, [], params));
});

gulp.task('build', function() {
childProcess.exec(['$PYTHON_CMD scripts/build.py']);
});
Expand All @@ -109,8 +66,4 @@ gulp.task('watch', function() {
}
});

if (isProdMode) {
gulp.task('start_devserver', ['gulpStartGae']);
} else {
gulp.task('start_devserver', ['gulpStartGae', 'watch']);
}
gulp.task('watch', ['watch']);
90 changes: 0 additions & 90 deletions scripts/gulp-start-gae-devserver.js

This file was deleted.

7 changes: 4 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ echo Starting GAE development server
# settings in feconf.py. Be careful with this -- you do not want to spam people
# accidentally!


($NODE_PATH/bin/node $NODE_MODULE_DIR/gulp/bin/gulp.js start_devserver --prod_env=$FORCE_PROD_MODE --gae_devserver_path=$GOOGLE_APP_ENGINE_HOME/dev_appserver.py --clear_datastore=$CLEAR_DATASTORE_ARG --enable_console=$ENABLE_CONSOLE_ARG)&

if ! [[ "$FORCE_PROD_MODE" == "True" ]]; then
($NODE_PATH/bin/node $NODE_MODULE_DIR/gulp/bin/gulp.js watch)&
fi
(python $GOOGLE_APP_ENGINE_HOME/dev_appserver.py $CLEAR_DATASTORE_ARG $ENABLE_CONSOLE_ARG --admin_host 0.0.0.0 --admin_port 8000 --host 0.0.0.0 --port 8181 --skip_sdk_update_check true app.yaml)&

# Wait for the servers to come up.
while ! nc -vz localhost 8181 >/dev/null 2>&1; do sleep 1; done
Expand Down

0 comments on commit 162dfe9

Please sign in to comment.