提交 0b459165 编写于 作者: C Christoph Held

spawn backend in development and production mode. Temporarily disabled integration tests.

上级 c7ca5799
...@@ -27,9 +27,11 @@ import conf from './conf'; ...@@ -27,9 +27,11 @@ import conf from './conf';
* follows the style guide, it is buildable and all tests pass. * follows the style guide, it is buildable and all tests pass.
* *
* This task should be used prior to publishing a change. * This task should be used prior to publishing a change.
*/ *
gulp.task('check', ['lint', 'build', 'test', 'integration-test:prod']); * TODO(cheld) enable integration tests once kuberentes cluster can be launched in travis
* gulp.task('check', ['lint', 'build', 'test', 'integration-test:prod']);
**/
gulp.task('check', ['lint', 'build', 'test']);
/** /**
* Lints all projects code files. This includes frontend source code, as well as, build scripts. * Lints all projects code files. This includes frontend source code, as well as, build scripts.
......
...@@ -45,9 +45,13 @@ export default { ...@@ -45,9 +45,13 @@ export default {
*/ */
testPackageName: 'test/backend', testPackageName: 'test/backend',
/** /**
* Port number of the development server started by Gulp. * Port number of the backend server. Only used during development.
*/ */
devServerPort: 8080, devServerPort: 9091,
/**
* Address for the Kubernetes API server.
*/
apiServerHost: 'http://localhost:8080',
}, },
/** /**
...@@ -64,6 +68,10 @@ export default { ...@@ -64,6 +68,10 @@ export default {
* Frontend application constants. * Frontend application constants.
*/ */
frontend: { frontend: {
/**
* Port number to access the dashboard UI
*/
serverPort: 9090,
/** /**
* The name of the root Angular module, i.e., the module that bootstraps the application. * The name of the root Angular module, i.e., the module that bootstraps the application.
*/ */
......
...@@ -29,7 +29,7 @@ var path = require('path'); ...@@ -29,7 +29,7 @@ var path = require('path');
* Schema can be found here: https://github.com/angular/protractor/blob/master/docs/referenceConf.js * Schema can be found here: https://github.com/angular/protractor/blob/master/docs/referenceConf.js
*/ */
exports.config = { exports.config = {
baseUrl: 'http://localhost:3000', baseUrl: 'http://localhost:' + conf.frontend.serverPort,
capabilities: { capabilities: {
// Firefox is used instead of Chrome, because that's what Travis supports best. // Firefox is used instead of Chrome, because that's what Travis supports best.
......
...@@ -67,6 +67,7 @@ function browserSyncInit(baseDir, includeBowerComponents) { ...@@ -67,6 +67,7 @@ function browserSyncInit(baseDir, includeBowerComponents) {
baseDir: baseDir, baseDir: baseDir,
middleware: proxyMiddleware(proxyMiddlewareOptions), middleware: proxyMiddleware(proxyMiddlewareOptions),
}, },
port: conf.frontend.serverPort,
startPath: '/', startPath: '/',
}; };
...@@ -96,31 +97,29 @@ function serveDevelopmentMode() { ...@@ -96,31 +97,29 @@ function serveDevelopmentMode() {
* Serves the application in development mode. Watches for changes in the source files to rebuild * Serves the application in development mode. Watches for changes in the source files to rebuild
* development artifacts. * development artifacts.
*/ */
gulp.task('serve:watch', ['watch'], serveDevelopmentMode); gulp.task('serve:watch', ['spawn-backend', 'watch'], serveDevelopmentMode);
/** /**
* Serves the application in development mode. * Serves the application in development mode.
*/ */
gulp.task('serve', ['index'], serveDevelopmentMode); gulp.task('serve', ['spawn-backend', 'index'], serveDevelopmentMode);
/** /**
* Serves the application in production mode. * Serves the application in production mode.
*/ */
gulp.task('serve:prod', ['build-frontend'], function () { gulp.task('serve:prod', ['spawn-backend:prod']);
browserSyncInit(conf.paths.distPublic, false);
});
/** /**
* Spawns new backend application process and finishes the task immediately. Previously spawned * Spawns new backend application process and finishes the task immediately. Previously spawned
* backend process is killed beforehand, if any. * backend process is killed beforehand, if any. The frontend pages are served by BrowserSync.
*/ */
gulp.task('spawn-backend', ['backend', 'kill-backend'], function () { gulp.task('spawn-backend', ['backend', 'kill-backend'], function () {
runningBackendProcess = child.spawn( runningBackendProcess = child.spawn(
path.join(conf.paths.serve, conf.backend.binaryName), path.join(conf.paths.serve, conf.backend.binaryName),
[`--port=${conf.backend.devServerPort}`], [`--apiserver-host=${conf.backend.apiServerHost}`, `--port=${conf.backend.devServerPort}`],
{stdio: 'inherit'}); {stdio: 'inherit'});
runningBackendProcess.on('exit', function() { runningBackendProcess.on('exit', function() {
...@@ -130,6 +129,24 @@ gulp.task('spawn-backend', ['backend', 'kill-backend'], function () { ...@@ -130,6 +129,24 @@ gulp.task('spawn-backend', ['backend', 'kill-backend'], function () {
}); });
/**
* Spawns new backend application process and finishes the task immediately. Previously spawned
* backend process is killed beforehand, if any. In production the backend does serve the frontend
* pages as well.
*/
gulp.task('spawn-backend:prod', ['build-frontend', 'backend:prod', 'kill-backend'], function () {
runningBackendProcess = child.spawn(
path.join(conf.paths.dist, conf.backend.binaryName),
[`--apiserver-host=${conf.backend.apiServerHost}`, `--port=${conf.frontend.serverPort}`],
{stdio: 'inherit', cwd: conf.paths.dist});
runningBackendProcess.on('exit', function() {
// Mark that there is no backend process running anymore.
runningBackendProcess = null;
});
});
/** /**
* Kills running backend process (if any). * Kills running backend process (if any).
*/ */
......
...@@ -24,10 +24,10 @@ import ( ...@@ -24,10 +24,10 @@ import (
) )
var ( var (
argPort = pflag.Int("port", 8080, "The port to listen to for incoming HTTP requests") argPort = pflag.Int("port", 9090, "The port to listen to for incoming HTTP requests")
argApiserverHost = pflag.String("apiserver-host", "", "The address of the Kubernetes Apiserver "+ argApiserverHost = pflag.String("apiserver-host", "", "The address of the Kubernetes Apiserver "+
"to connect to in the format of protocol://address:port, e.g., "+ "to connect to in the format of protocol://address:port, e.g., "+
"http://localhost:8001. If not specified, the assumption is that the binary runs in a"+ "http://localhost:8080. If not specified, the assumption is that the binary runs inside a"+
"Kubernetes cluster and local discovery is attempted.") "Kubernetes cluster and local discovery is attempted.")
) )
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册