设为首页 收藏本站
查看: 600|回复: 0

[经验分享] DevOps(9)Build the NodeJS Env

[复制链接]

尚未签到

发表于 2017-2-21 13:06:50 | 显示全部楼层 |阅读模式
DevOps(9)Build the NodeJS Env
 
1. Memcached and Monitor
Command to start memcached
>memcached -d -m 50 -p 11211 -u carl -l 0.0.0.0
 
Install the Memcache-Top
> wget https://memcache-top.googlecode.com/files/memcache-top-v0.6
Prepare the right directory
> mkdir /home/carl/tool/memcache-top-v0.6
> mkdir /home/carl/tool/memcache-top-v0.6/bin
> mv memcache-top-v0.6 /home/carl/tool/memcache-top-v0.6/bin/memcache-top
> chmod a+x /opt/memcache-top/bin/memcache-top
 
Start the Monitor Tool
> memcache-top --sleep 3 --instance ubuntu-dev1,ubuntu-dev2
 
The output will be as follow:
memcache-top v0.6 (default port: 11211, color: on, refresh: 3 seconds)

INSTANCE USAGE HIT % CONN TIME EVICT/s READ/s WRITE/s
ubuntu-dev1:11211 0.0%
0.0% 5 1.6ms 0.0 2 367
ubuntu-dev2:11211 0.0%
0.0% 5 1.5ms 0.0 2 367

AVERAGE: 0.0% 0.0% 5 1.6ms 0.0 2 367

TOTAL: 0B/ 0.1GB 10 3.1ms 0.0 4 733
(ctrl-c to quit.)
 
2. Prepare the NodeJS Env
follow
http://sillycat.iteye.com/blog/2065705
 
I was using version python 2.7.6 and node 0.10.28. I will try different this time on my local and VM.
> wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz
> ./configure --prefix=/home/carl/tool/node-v0.12.0
make it and install that.
> node -v
v0.12.0
 
Install gulp
> sudo npm install -g gulp
 
or
 
> npm install --global gulp
 
> gulp -version
[13:31:35] CLI version 3.8.11
 
Install the NODEJS Plugin in jenkins
Install the GitHub Plugin in Jenkins
Install the  SSH plugin in Jenkins
 
3. Prepare deploy Env
http://sillycat.iteye.com/blog/2072390
 
> sudo apt-get install git
> npm install pm2 -g
> pm2 -v
[PM2] Spawning PM2 daemon
[PM2] PM2 Successfully daemonized
0.12.7
 
gulp command to get the dist and deploy
>gulp serve
>gulp clean
>gulp dist
>gulp deploy
 
gulp config
/*jslint node: true */
'use strict';
 
//gulp & plugins
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var nodemon = require('gulp-nodemon');
var gutil = require('gulp-util');
var tar = require('gulp-tar');
var gzip = require('gulp-gzip');
var del = require('del');
var artifactoryUpload = require('gulp-artifactory-upload');
 
var project = {
name : ’sillycat-secure-proxy',
version : '1.0',
}
 
var artifactory = {
url : 'http://ubuntu-pilot:8080/artifactory/libs-release-local/',
username : 'deployer',
password : 'deployer',
path : ‘com/sillycat/sillycat-secure-proxy/'
}
 
var paths = {
main : 'app.js',
tests : 'test/**/*.js',
sources : [ '**/*.js', '!node_modules/**', '!gulpfile.js', '!dist/**'],
deploys : [ '**/*.*',
'!gulpfile.js',
'!package.json',
'!README.md',
'!dist/**',
'!test/**',
'!node_modules/gulp/**',
'!node_modules/gulp-*/**',
'!node_modules/del/**'],
};
 
gulp.task('clean', del.bind(null, ['dist']));
 
gulp.task('dist', function() {
gulp.src(paths.deploys)
.pipe(tar(project.name + '-' + project.version + '.tar'))
.pipe(gzip())
.pipe(gulp.dest('./dist/'));
});
 
gulp.task( 'deploy', function() {
return gulp.src('./dist/' + project.name + '-' + project.version + '.tar.gz')
.pipe( artifactoryUpload( {
url: artifactory.url + artifactory.path,
username: artifactory.username, // optional
password: artifactory.password, // optional,
rename: function( filename ) { return filename; } // optional
} ) )
.on('error', gutil.log);
} );
 
// lint all of our js source files
gulp.task('lint', function (){
return gulp.src(paths.sources)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
 
// run mocha tests
gulp.task('test', function (){
return gulp.src(paths.tests, {read: false})
.pipe(mocha({reporter: 'list'}))
.on('error', gutil.log);
});
 
//run app using nodemon
gulp.task('serve', [], function(){
return nodemon({
script: 'app.js',
watch : paths.sources
});
});
 
Package managed by npm
{
"devDependencies": {
"gulp": "^3.8.5",
"gulp-jshint": "^1.6.3",
"gulp-mocha" : "^1.1.1",
"gulp-nodemon" : "^1.0.4",
"gulp-util" : "^3.0.1",
"gulp-tar" : "^1.4.0",
"gulp-gzip" : "^1.0.0",
"del" : "^1.1.1",
"gulp-artifactory-upload" : "^1.1.0",
"express" : "^4.12.2"
},
"engines": {
"node": ">=0.11.0"
},
"private": true
}
 
Unzip the binary
>mkdir sillycat-secure-proxy-1.0
>tar zxvf sillycat-secure-proxy-1.0.tar.gz -C ./sillycat-secure-proxy-1.0
 
Deploy the binary
Download the binary from artifactory
>mkdir sillycat-secure-proxy-1.0
>tar zxvf sillycat-secure-proxy-1.0.tar.gz -C ./sillycat-secure-proxy-1.0
>pm2 start app.js --name sillycat-secure-proxy -i max
 
Stop the binary
>pm2 stop sillycat-secure-proxy
 
Restart the binary
>pm2 restart sillycat-secure-proxy
 
Watch all the node applications
>pm2 list
 
Jenkins can finish the deployer work
. ~/.profile
cd /opt/sillycat-secure-proxy
pm2 stop sillycat-secure-proxy
rm -fr *
wget --user=deployer --password=deployer http://ubuntu-pilot:8080/artifactory/libs-release-local/com/sillycat/sillycat-secure-proxy/sillycat-secure-proxy-1.0.tar.gz
tar zxf sillycat-secure-proxy-1.0.tar.gz
pm2 restart sillycat-secure-proxy
 
Or
 
. ~/.profile
cd /opt/sillycat-secure-proxy
pm2 delete sillycat-secure-proxy
rm -fr *
wget --user=deployer --password=deployer http://ubuntu-pilot:8080/artifactory/libs-release-local/com/sillycat/sillycat-secure-proxy/sillycat-secure-proxy-1.0.tar.gz
tar zxf sillycat-secure-proxy-1.0.tar.gz
pm2 start app.js --name sillycat-secure-proxy -i max
 
References:
http://blog.fedecarg.com/2009/11/29/command-line-memcached-stat-reporter/
https://code.google.com/p/memcache-top/
 
http://sillycat.iteye.com/blog/2155801
 
Mongodb
http://sillycat.iteye.com/blog/603890
http://sillycat.iteye.com/blog/1547291
http://sillycat.iteye.com/blog/1547292
http://sillycat.iteye.com/blog/1547294
http://sillycat.iteye.com/blog/1965857
http://sillycat.iteye.com/blog/1965880
http://sillycat.iteye.com/blog/2066225
 
gulp
http://sillycat.iteye.com/blog/2150867
http://sillycat.iteye.com/blog/2155801
http://gulpjs.com/
 

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-345324-1-1.html 上篇帖子: 用nodejs处理文件上传(2) 下篇帖子: NodeJS初探之一——神秘的服务器端JS(转)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表