Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
fbb68061
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fbb68061
编写于
11月 02, 2015
作者:
P
Piotr Bryk
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #44 from kubernetes/run-backend-on-serve
Spawn backend application process on serve task
上级
6c7c22db
690b146d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
14 deletion
+84
-14
.gitignore
.gitignore
+2
-1
build/backend.js
build/backend.js
+4
-3
build/build.js
build/build.js
+14
-8
build/conf.js
build/conf.js
+11
-0
build/serve.js
build/serve.js
+53
-2
未找到文件。
.gitignore
浏览文件 @
fbb68061
...
...
@@ -3,9 +3,10 @@ node_modules/
bower_components/
## Build and test artifacts
coverag
e/
.go_workspac
e/
.sass-cache/
.tmp/
coverage/
dist/
## IDE specific files
...
...
build/backend.js
浏览文件 @
fbb68061
...
...
@@ -45,7 +45,7 @@ const goBackendDependencies = [
*/
function
spawnGoProcess
(
args
,
doneFn
,
opt_env
)
{
let
goTask
=
child
.
spawn
(
'
go
'
,
args
,
{
env
:
lodash
.
merge
(
process
.
env
,
{
GOPATH
:
conf
.
paths
.
backendTmp
},
opt_env
||
{}),
env
:
lodash
.
merge
(
process
.
env
,
{
GOPATH
:
conf
.
paths
.
goWorkspace
},
opt_env
||
{}),
});
// Call Gulp callback on task exit. This has to be done to make Gulp dependency management
...
...
@@ -75,7 +75,7 @@ function spawnGoProcess(args, doneFn, opt_env) {
gulp
.
task
(
'
backend
'
,
[
'
backend-dependencies
'
],
function
(
doneFn
)
{
spawnGoProcess
([
'
build
'
,
'
-o
'
,
path
.
join
(
conf
.
paths
.
serve
,
'
dashboard
'
),
'
-o
'
,
path
.
join
(
conf
.
paths
.
serve
,
conf
.
backend
.
binaryName
),
path
.
join
(
conf
.
paths
.
backendSrc
,
'
dashboard.go
'
),
],
doneFn
);
});
...
...
@@ -89,7 +89,8 @@ gulp.task('backend', ['backend-dependencies'], function(doneFn) {
* dependencies inside it and is targeted for Linux.
*/
gulp
.
task
(
'
backend:prod
'
,
[
'
backend-dependencies
'
],
function
(
doneFn
)
{
let
outputBinaryPath
=
path
.
join
(
conf
.
paths
.
dist
,
'
dashboard
'
);
let
outputBinaryPath
=
path
.
join
(
conf
.
paths
.
dist
,
conf
.
backend
.
binaryName
);
// Delete output binary first. This is required because prod build does not override it.
del
(
outputBinaryPath
)
.
then
(
function
()
{
...
...
build/build.js
浏览文件 @
fbb68061
...
...
@@ -32,14 +32,8 @@ import conf from './conf';
/**
* Builds production package and places it in the dist directory.
*
* Following steps are done here:
* 1. Vendor CSS and JS files are concatenated and minified.
* 2. index.html is minified.
* 3. CSS and JS assets are suffixed with version hash.
* 4. Everything is saved in the dist directory.
*/
gulp
.
task
(
'
build
'
,
[
'
assets
'
,
'
backend:prod
'
,
'
index:pro
d
'
],
function
()
{
gulp
.
task
(
'
build
'
,
[
'
backend:prod
'
,
'
build-fronten
d
'
],
function
()
{
let
htmlFilter
=
gulpFilter
(
'
*.html
'
,
{
restore
:
true
});
let
vendorCssFilter
=
gulpFilter
(
'
**/vendor.css
'
,
{
restore
:
true
});
let
vendorJsFilter
=
gulpFilter
(
'
**/vendor.js
'
,
{
restore
:
true
});
...
...
@@ -75,6 +69,18 @@ gulp.task('build', ['assets', 'backend:prod', 'index:prod'], function () {
});
/**
* Builds production version of the frontend application.
*
* Following steps are done here:
* 1. Vendor CSS and JS files are concatenated and minified.
* 2. index.html is minified.
* 3. CSS and JS assets are suffixed with version hash.
* 4. Everything is saved in the dist directory.
*/
gulp
.
task
(
'
build-frontend
'
,
[
'
assets
'
,
'
index:prod
'
]);
/**
* Copies assets to the dist directory.
*/
...
...
@@ -88,5 +94,5 @@ gulp.task('assets', function () {
* Cleans all build artifacts.
*/
gulp
.
task
(
'
clean
'
,
function
()
{
return
del
([
path
.
join
(
conf
.
paths
.
dist
,
'
/
'
),
path
.
join
(
conf
.
paths
.
tmp
,
'
/
'
)
]);
return
del
([
conf
.
paths
.
dist
,
conf
.
paths
.
goWorkspace
,
conf
.
paths
.
tmp
]);
});
build/conf.js
浏览文件 @
fbb68061
...
...
@@ -28,6 +28,16 @@ const basePath = path.join(__dirname, '../');
* Exported configuration object with common constants used in build pipeline.
*/
export
default
{
/**
* Backend application constants.
*/
backend
:
{
/**
* The name of the backend binary.
*/
binaryName
:
'
dashboard
'
,
},
/**
* Deployment constants configuration.
*/
...
...
@@ -64,6 +74,7 @@ export default {
externs
:
path
.
join
(
basePath
,
'
src/app/externs
'
),
frontendSrc
:
path
.
join
(
basePath
,
'
src/app/frontend
'
),
frontendTest
:
path
.
join
(
basePath
,
'
src/test/frontend
'
),
goWorkspace
:
path
.
join
(
basePath
,
'
.go_workspace
'
),
integrationTest
:
path
.
join
(
basePath
,
'
src/test/integration
'
),
karmaConf
:
path
.
join
(
basePath
,
'
build/karma.conf.js
'
),
nodeModules
:
path
.
join
(
basePath
,
'
node_modules
'
),
...
...
build/serve.js
浏览文件 @
fbb68061
...
...
@@ -17,12 +17,21 @@
*/
import
browserSync
from
'
browser-sync
'
;
import
browserSyncSpa
from
'
browser-sync-spa
'
;
import
child
from
'
child_process
'
;
import
gulp
from
'
gulp
'
;
import
path
from
'
path
'
;
import
conf
from
'
./conf
'
;
/**
* Currently running backend process object. Null if the backend is not running.
*
* @type {?child.ChildProcess}
*/
let
runningBackendProcess
=
null
;
/**
* Initializes BrowserSync tool. Files are server from baseDir directory list.
*
...
...
@@ -35,6 +44,7 @@ function browserSyncInit(baseDir) {
}));
browserSync
.
instance
=
browserSync
.
init
({
// TODO(bryk): Add proxy to the backend here.
startPath
:
'
/
'
,
server
:
{
baseDir
:
baseDir
,
...
...
@@ -47,7 +57,7 @@ function browserSyncInit(baseDir) {
/**
* Serves the application in development mode.
*/
gulp
.
task
(
'
serve
'
,
[
'
watch
'
],
function
()
{
gulp
.
task
(
'
serve
'
,
[
'
spawn-backend
'
,
'
watch
'
],
function
()
{
browserSyncInit
([
conf
.
paths
.
serve
,
conf
.
paths
.
frontendSrc
,
// For angular templates to work.
...
...
@@ -60,11 +70,51 @@ gulp.task('serve', ['watch'], function () {
/**
* Serves the application in production mode.
*/
gulp
.
task
(
'
serve:prod
'
,
[
'
build
'
],
function
()
{
gulp
.
task
(
'
serve:prod
'
,
[
'
build
-frontend
'
,
'
spawn-backend
'
],
function
()
{
browserSyncInit
(
conf
.
paths
.
dist
);
});
/**
* Spawns new backend application process and finishes the task immediately. Previously spawned
* backend process is killed beforehand, if any.
*/
gulp
.
task
(
'
spawn-backend
'
,
[
'
backend
'
,
'
kill-backend
'
],
function
()
{
runningBackendProcess
=
child
.
spawn
(
path
.
join
(
conf
.
paths
.
serve
,
conf
.
backend
.
binaryName
));
runningBackendProcess
.
on
(
'
exit
'
,
function
()
{
// Mark that there is no backend process running anymore.
runningBackendProcess
=
null
;
});
runningBackendProcess
.
stdout
.
on
(
'
data
'
,
function
(
data
)
{
console
.
log
(
''
+
data
);
});
runningBackendProcess
.
stderr
.
on
(
'
data
'
,
function
(
data
)
{
console
.
error
(
''
+
data
);
});
});
/**
* Kills running backend process (if any).
*/
gulp
.
task
(
'
kill-backend
'
,
function
(
doneFn
)
{
if
(
runningBackendProcess
)
{
runningBackendProcess
.
on
(
'
exit
'
,
function
()
{
// Mark that there is no backend process running anymore.
runningBackendProcess
=
null
;
// Finish the task only when the backend is actually killed.
doneFn
();
});
runningBackendProcess
.
kill
();
}
else
{
doneFn
();
}
});
/**
* Watches for changes in source files and runs Gulp tasks to rebuild them.
*/
...
...
@@ -84,4 +134,5 @@ gulp.task('watch', ['index'], function () {
});
gulp
.
watch
(
path
.
join
(
conf
.
paths
.
frontendSrc
,
'
**/*.js
'
),
[
'
scripts
'
]);
gulp
.
watch
(
path
.
join
(
conf
.
paths
.
backendSrc
,
'
**/*.go
'
),
[
'
spawn-backend
'
]);
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录