SlideShare a Scribd company logo
Moden FrontEnd Devops
104 兒童美術館自動部署分享
Kenny Lee
Kenny Lee
平台研發 Team Leader / Devops 專案經理 /
cicisasa 架構規劃開發
網站軟體架構的狂熱分子,擅長各項新技術的研發導入
Email : microbean@gmail.com
Github : https://github.com/KennyTw
104+ : http://plus.104.com.tw/李坤承
Today Topic
cicisasa tech stack
Why FrontEndDevops ?
由於前端開發技術越來越複雜
So many Js & CSS
但是許多 Ops偏向後端技術
他們不懂
為何前端如此複雜
所以我們需要一個好的架構
及上線規劃
而且我們也需要了解一些後端技術
FrontEndDevops
Plan& Goal
使用自動化
降低人工操作的成本
需要有好的 JS/CSS 框架
利用HotDeploy
實現
Zero Downtime
CI/CD
實現隨時都可以上線
500 error
需要被 handle
cicisasa 是如何做到呢 ?
免費儲存孩子圖畫的網路空間
保存孩子的童年回憶及創意
技術實驗場
cicisasa.com
Code language
Light,Easy,Rich ecosystem
Database
Light,High Performance
FrontEnd Framework
simple and quickly
JS Framework
Light,simple
Backbone.js
Task manager
rich ecosystem
Dependency manager
require('modules') is simple
Continuous Integration
most popular
Perfectly integrates with GitHub
Template Engine
Both Client/Server render
Test Framework
Love “TJ Holowaychuk” (ejs..)
supertest , should
Client/Server
Avoid too many ajax request
Cicisasa HotDeploy
“naught”
• Zero downtime deployment project
• Node cluster : Clustering in Node.js allows you to
create separate processes which can share same
server port
• naught start --ipc-file server.ipc
--stdout stdout.log
--stderr stderr.log ./apps/server/server.js
• naught deploy server.ipc
var domain = require('domain') ,
serverDomain = domain.create() ,
gracefulExit = require('express-graceful-exit');
serverDomain.run(function() {
var server = http.createServer(app);
process.on('message', function(message) {
if (message === 'shutdown')
{ gracefulExit.gracefulExitHandler(app,server,{log:true,
suicideTimeout:6*1000});
server.js
naught
Next
Cicisasa Deploy Procedure
Azure File Storage
Web Server
rsync
Developer
Next
HotDeploy
Deploy Procedure
Code Commit
• HotDeploy
• CI initial
(Npm install , redis-db , test data)
• JS/css trasform& copy &
pack & uglify/minify
• Test
• Source Code transfer to
Azure
Next
CI initial (.travis.yml)
services:
- redis-server
before_install:
₋ npm install -g grunt-cli
₋ npm install -g bower@1.4.1
₋ npm install -g azure-cli
₋ npm install
₋ node travis_ini.js
var redis = require('redis');
var db = redis.createClient();
db.set("data","helloworld");
Next
CI initial (.travis.yml)
₋ chmod -R 777 ./travis_notify.sh
₋ chmod -R 777 ./travis_grunt.sh
₋ chmod -R 777 ./travis_azure.sh
₋ chmod -R 777 ./app
₋ bower install
JS/css trasform& copy & pack & uglify
₋ ./travis_grunt.sh
if [ "$TRAVIS_BRANCH" == "master" ]; then
grunt ci
grunt test
fi
grunt.registerTask('ci',['shell:start
','shell:bower','shell:npm','concat',
'cssmin','browserify:prod','uglify','
shell:deploy']);
Gruntfile.js
(.travis.yml)
Test
Gruntfile.js
grunt.registerTask('test', ['mochaTest:test']);
mochaTest: { test: { src: ['test/*.js']}}
var request = require('supertest');
var should = require('should');
describe('Basic Server Test',
function(){ this.timeout(10000); //timeout with 10 secs
it('Get / should respond 200 and check some keyword',
function(done){
request("http://127.0.0.1:3000")
.get('/')
.expect(200, done)
.end(function(err,res) {
res.text.should.containEql('/js/bundle.js');
done(err); });
/test/RootBasicTest.js (ServerSide Test)
Next
Test
/test/RootJsTest.js (Client Side Test)
var request = require('supertest');
var should = require('should');
var phantom = require('phantom');
describe('Basic Client Test with PhantomJS', function(){
var page;
…
it('get / should return data back and no js error',
function (done) {
page.set('onError', function(error) { done(error); });
page.open('http://127.0.0.1:3000', function (status) {
page.evaluate(
function () { return document.title; } ,
function (result) {
if (result.length > 0) { done(); } else
{ done("document.title null"); }
Next
SourceCode transfer to Azure
- ./travis_azure.sh
echo "tar files..."
tar -zcvf "./source.tgz" "./"
echo "Uploading files..."
azure storage file upload -q "./source.tgz" deploy
HotDeploy
- ./travis_notify.sh
if [ "$TRAVIS_BRANCH" == "master" ]; then
echo "master deploy"
curl --data ""
http://ithomefedevops.cloudapp.net:3000/travis_web_hook
fi
HotDeploy
server.js
app.post('/travis_web_hook',function(req, res) {
spawn('grunt', [],{cwd: '/home/azureuser/code'});
res.end();
});
Gruntfile.js
grunt.registerTask('default',['shell:tar',
'shell:rsync','shell:npm','shell:deploy']);
Resource Here
https://github.com/KennyTw/ITHomeFEDevops
QA
Q:專案規模到何種程度的時候
需要安裝自動部署
Q: Javascript Unit Test與
End to End Test的重要性,
是否都得進行?
Q: 自動部屬的學習門檻高嗎?
Q: 自動部署的可靠性
Q: 是否透過git hook自動deploy?
Q: 請問關於自動部署的技術核心
是如何達成的?
Q: 適用於雲端主機嗎?
若有多台主機,可以一次搞定嗎?
Q: 對不停機更新的自動部署方式
(資料庫更新、網站結構更新...等)
Q: 之前台灣業界網頁設計師總是包山包海的做,
現在有了前端工程師的職位,總算開始有些釐清,
但目前也發現網頁設計師開始分裂為
網頁視覺設計師與網頁前端設計師
我想問的是台灣業界
是否應該再開始對職務的定義正名有更清楚的解釋
Thank You

More Related Content

PPTX
Node.js Spplication Scaling
KEY
Node workShop Basic
PDF
ZinoUI PHP Server wrappers
PDF
Continuous Integration for front-end JavaScript
PPT
Introducing to node.js
PPT
PDF
What the web platform (and your app!) can learn from Node.js
PPTX
Managing the .NET Compiler
Node.js Spplication Scaling
Node workShop Basic
ZinoUI PHP Server wrappers
Continuous Integration for front-end JavaScript
Introducing to node.js
What the web platform (and your app!) can learn from Node.js
Managing the .NET Compiler

What's hot (20)

PDF
All aboard the NodeJS Express
PDF
(WS14) Sasa Matijasic - Node.js i "novi" web
PPTX
Node.js in a heterogeneous system
PDF
"今" 使えるJavaScriptのトレンド
PDF
Server-Side JavaScript Developement - Node.JS Quick Tour
PDF
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
PPTX
2015 - Basta! 2015, DE: JavaScript und build
PPTX
Jk rubyslava 25
PPTX
Beyond Golden Containers: Complementing Docker with Puppet
PDF
PDF
Angular2 ecosystem
ODP
Presentation of JSConf.eu
PPTX
Zero to Online Cafe in 20 minutes
PDF
Bower & Grunt - A practical workflow
PDF
Gazelle - Plack Handler for performance freaks #yokohamapm
PPTX
Band criando api nodejs com type script
KEY
About Data::ObjectDriver
PPT
Building your first Node app with Connect & Express
PDF
Production Ready Javascript With Grunt
PPTX
Chromium Embedded Framework + Go at Brooklyn JS
All aboard the NodeJS Express
(WS14) Sasa Matijasic - Node.js i "novi" web
Node.js in a heterogeneous system
"今" 使えるJavaScriptのトレンド
Server-Side JavaScript Developement - Node.JS Quick Tour
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
2015 - Basta! 2015, DE: JavaScript und build
Jk rubyslava 25
Beyond Golden Containers: Complementing Docker with Puppet
Angular2 ecosystem
Presentation of JSConf.eu
Zero to Online Cafe in 20 minutes
Bower & Grunt - A practical workflow
Gazelle - Plack Handler for performance freaks #yokohamapm
Band criando api nodejs com type script
About Data::ObjectDriver
Building your first Node app with Connect & Express
Production Ready Javascript With Grunt
Chromium Embedded Framework + Go at Brooklyn JS
Ad

Similar to ModemFrontEndops (20)

PPTX
Real World Lessons on the Pain Points of Node.js Applications
PDF
フロントエンドエンジニア(仮) 〜え、ちょっとフロントやること多すぎじゃない!?〜
PDF
Get Grulping with JavaScript Task Runners
PDF
Tooling per il tema in Drupal 8
PDF
Tooling per il tema in Drupal 8
PDF
taking-flight-tailwind-css for beginners.pdf
PPTX
Kraken
PDF
Get Grulping with JavaScript Task Runners (Matt Gifford)
PDF
Node.js flow control
PDF
Kraken Front-Trends
PDF
Charla EHU Noviembre 2014 - Desarrollo Web
PDF
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
PDF
Security 202 - Are you sure your site is secure?
PDF
Performance patterns
PPTX
drupal ci cd concept cornel univercity.pptx
PPT
Web 2.0 Expo: Even Faster Web Sites
PPT
Web20expo 20080425
PDF
Practical guide for front-end development for django devs
PDF
NodeJS for Beginner
PDF
Workflow automation for Front-end web applications
Real World Lessons on the Pain Points of Node.js Applications
フロントエンドエンジニア(仮) 〜え、ちょっとフロントやること多すぎじゃない!?〜
Get Grulping with JavaScript Task Runners
Tooling per il tema in Drupal 8
Tooling per il tema in Drupal 8
taking-flight-tailwind-css for beginners.pdf
Kraken
Get Grulping with JavaScript Task Runners (Matt Gifford)
Node.js flow control
Kraken Front-Trends
Charla EHU Noviembre 2014 - Desarrollo Web
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
Security 202 - Are you sure your site is secure?
Performance patterns
drupal ci cd concept cornel univercity.pptx
Web 2.0 Expo: Even Faster Web Sites
Web20expo 20080425
Practical guide for front-end development for django devs
NodeJS for Beginner
Workflow automation for Front-end web applications
Ad

ModemFrontEndops