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

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

上级 c7ca5799
......@@ -27,9 +27,11 @@ import conf from './conf';
* follows the style guide, it is buildable and all tests pass.
*
* 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.
......
......@@ -45,9 +45,13 @@ export default {
*/
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 {
* Frontend application constants.
*/
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.
*/
......
......@@ -29,7 +29,7 @@ var path = require('path');
* Schema can be found here: https://github.com/angular/protractor/blob/master/docs/referenceConf.js
*/
exports.config = {
baseUrl: 'http://localhost:3000',
baseUrl: 'http://localhost:' + conf.frontend.serverPort,
capabilities: {
// Firefox is used instead of Chrome, because that's what Travis supports best.
......
......@@ -67,6 +67,7 @@ function browserSyncInit(baseDir, includeBowerComponents) {
baseDir: baseDir,
middleware: proxyMiddleware(proxyMiddlewareOptions),
},
port: conf.frontend.serverPort,
startPath: '/',
};
......@@ -96,31 +97,29 @@ function serveDevelopmentMode() {
* Serves the application in development mode. Watches for changes in the source files to rebuild
* development artifacts.
*/
gulp.task('serve:watch', ['watch'], serveDevelopmentMode);
gulp.task('serve:watch', ['spawn-backend', 'watch'], serveDevelopmentMode);
/**
* Serves the application in development mode.
*/
gulp.task('serve', ['index'], serveDevelopmentMode);
gulp.task('serve', ['spawn-backend', 'index'], serveDevelopmentMode);
/**
* Serves the application in production mode.
*/
gulp.task('serve:prod', ['build-frontend'], function () {
browserSyncInit(conf.paths.distPublic, false);
});
gulp.task('serve:prod', ['spawn-backend:prod']);
/**
* 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 () {
runningBackendProcess = child.spawn(
path.join(conf.paths.serve, conf.backend.binaryName),
[`--port=${conf.backend.devServerPort}`],
[`--apiserver-host=${conf.backend.apiServerHost}`, `--port=${conf.backend.devServerPort}`],
{stdio: 'inherit'});
runningBackendProcess.on('exit', 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).
*/
......
......@@ -24,10 +24,10 @@ import (
)
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 "+
"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.")
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册