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
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
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
I was using version python 2.7.6 and node 0.10.28. I will try different this time on my local and VM.
> ./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
> sudo apt-get install git
> npm install pm2 -g
> pm2 -v
[PM2] Spawning PM2 daemon
[PM2] PM2 Successfully daemonized
[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:
Mongodb
gulp
相关推荐
git commit -m“第一次提交” ...cd fullcycle-devops-nginx_nodejs/node npm install cd .. docker-compose build docker-compose up -d 参数: http://localhost:8080?name=[nome_que_sera_inser
Starting and Scaling DevOps in the Enterprise,Starting and Scaling DevOps in the Enterprise
devops-ci-env 创建持续集成环境的脚本使用 Docker/Gerrit/GitLab/Jenkins/
The Accelerate State of DevOps Report is the largest and longestrunning research of its kind. It represents five years of work surveying over 30,000 technical professionals worldwide. The results ...
The DevOps Adoption Playbook provides practical, actionable, real-world guidance on implementing DevOps at enterprise scale. Author Sanjeev Sharma heads the DevOps practice for IBM; in this book, he ...
The DevOps 2.4 Toolkit
The result is The DevOps 2.0 Toolkit: Automating the Continuous Deployment Pipeline with Containerized Microservices. With the third book, the initial scope became even more obscure. I started ...
If you do not, please read The DevOps 2.0 Toolkit: Automating the Continuous Deployment Pipeline with Containerized Microservices for a general overview of DevOps tools and practices and The DevOps ...
适用于Azure功能的Azure Devops Build Manager :construction: 该项目目前正在进行中。 请不要在生产中使用,因为我们希望随着时间的推移会有所发展。 :construction: 该项目提供了类AzureDevopsBuildManager和...
根据给定的文件信息,我们将聚焦于“DevOps on the Microsoft Stack”这一主题,以下将详细解读该主题所涉及的知识点。 知识点一:DevOps概述 DevOps是一个文化和实践的结合体,目的是改变软件开发(Dev)和信息...
Jenkins Docker and DevOps The Innovation Catalysts,Jenkins Docker and DevOps The Innovation Catalysts
标题 "azure-devops-build.mjT-script-custom-agent" 暗示了我们正在讨论一个与Azure DevOps相关的构建过程,特别是涉及到使用自定义脚本(mjT脚本)和自定义代理(custom agent)。Azure DevOps是微软提供的一个全...
before we get into the meat of the book, I want to take a moment to explain why it is so important to change the way we approach IT delivery. We obviously didn’t choose to be in the situation we are ...