Skip to content
Snippets Groups Projects
Commit e36ca953 authored by matt01671's avatar matt01671
Browse files

cleaned directory

parent cd6faf82
Branches
No related tags found
No related merge requests found
Showing
with 93657 additions and 441 deletions
export declare -a nodes=(172.26.133.58 172.26.132.78 172.26.133.15) #NEED TO AUTOMATE
export user=admin
export pass=admin
export VERSION='3.0.0'
export cookie='a192aeb9904e6590849337933b000c99'
export uuid='a192aeb9904e6590849337933b001159'
export masternode=`echo ${nodes} | cut -f1 -d' '`
export declare -a othernodes=`echo ${nodes[@]} | sed s/${masternode}//`
export size=${#nodes[@]}
curl -XPUT "http://${user}:${pass}@${masternode}:5984/twitter"
curl -XPOST "http://${user}:${pass}@${masternode}:5984/twitter/_bulk_docs " --header "Content-Type: application/json" \
--data @../twitter/data.json
<<<<<<< HEAD
# ---
# - name: check if packages exits
# package_facts:
# manager: auto
# - name: 'install all the dependencies '
# tags: always
# become: yes
# apt:
# name: ['nodejs','npm']
# state: latest
# install_recommends: no
# update_cache: yes
# - debug:
# msg: "node and npm installed"
# - name: make sure the latest npm is installed
# tags: 'node'
# become: yes
# npm:
# name: npm
# global: yes
# state: latest
# - name: install pm2 server
# tags: 'pm2'
# become: yes
# npm:
# name: pm2
# global: yes
# state: latest
# - name: install react
# tags: 'react'
# become: yes
# npm:
# name: create-react-app
# global: yes
# state: present
# - name: traverse into the project directory.
# become: yes
# shell: cd
# args:
# chdir: /var/lib/react
# register: dir_changed
# - name: clone git repo
# become: yes
# git:
# repo: https://github.com/advait22/react-server.git
# dest: /var/lib/react
# force: yes
# - debug:
# msg: 'git repo cloned'
# when: dir_changed.rc == 0
# - name: change working directory to the app
# become: yes
# shell: cd
# args:
# chdir: /var/lib/react/express_react_example
# register: server
# - name: install all the packages for server
# become: yes
# npm:
# path: /var/lib/react/express_react_example/
# name: install
# - debug:
# msg: 'inside server'
# when: server.rc == 0
# - name: install dependencies
# become: yes
# command: npm install --save express
# - debug:
# msg: 'Client express installed'
# when: server.rc == 0
# - name: change working directory to the client
# become: yes
# shell: cd
# args:
# chdir: /var/lib/react/express_react_example/client
# register: client
# - name: install dependencies
# become: yes
# npm:
# path: /var/lib/react/express_react_example/client
# name: install
# - debug:
# msg: 'Client Dependencies installed'
# when: client.rc == 0
# - name: Ansible check directory exists build in client.
# stat:
# path: /var/lib/react/express_react_example/client/build
# register: files_to_delete
# - name: delete previous build folder
# become: yes
# shell: rm -rf build
# args:
# chdir: /var/lib/react/express_react_example/client/
# register: build_delete
# - debug:
# msg: "build deleted"
# when: files_to_delete.stat.exists == true
# ###workaround for react js bug in build command
# - name: delete dependencies on client
# become: yes
# shell: rm -rf node_modules
# args:
# chdir: /var/lib/react/express_react_example/client/
# register: deleted_modules
# - debug:
# msg: 'Client Dependencies delete'
# - name: clear npm cache
# tags: 'clear cache'
# become: yes
# shell: npm cache clean --force
# args:
# chdir: /var/lib/react/express_react_example/client
# register: cache_cleaned
# when: deleted_modules.rc == 0
# - name: install dependencies
# become: yes
# npm:
# path: /var/lib/react/express_react_example/client
# name: install
# - debug:
# msg: 'Client Dependencies installed'
# when: cache_cleaned.rc == 0
# - name: install react scripts
# tags: 'react scripts'
# become: yes
# shell: npm install --save react-scripts@3.0.1 react react-dom
# args:
# chdir: /var/lib/react/express_react_example/client
# register: react_scripts
# when: cache_cleaned.rc == 0
# #################################################################
# - name : compile the new build
# tags: build
# become: yes
# shell: npm run build
# args:
# chdir: /var/lib/react/express_react_example/client
# - debug:
# msg: 'new build successfull'
# - name: Ansible check directory exists build in server.
# stat:
# path: /var/lib/react/express_react_example/build
# register: files_to_delete_from_server
# - name: delete previous build folder in server
# become: yes
# shell: rm -rf build
# args:
# chdir: /var/lib/react/express_react_example/
# register: build_delete_server
# - debug:
# msg: "deleting old build from server"
# when: files_to_delete_from_server.stat.exists == true
# - name: copy new build to parent folder
# become: yes
# command: mv /var/lib/react/express_react_example/client/build /var/lib/react/express_react_example
# register: build_copy
# - debug:
# msg: 'build copied'
# when: build_delete_server.rc == 0
# - name: stop all the running server
# become: yes
# command: pm2 stop all
# register: stop_server
# - debug:
# msg: 'all servers stopped'
# # when: build_copy.rc == 0
=======
---
- name: check if packages exits
package_facts:
......@@ -382,17 +187,9 @@
command: forever list
register: forever_list
changed_when: false
>>>>>>> 526fcc749ba8644fccb39286d817d314a38308f0
- name: stop if the server is running
become: yes
<<<<<<< HEAD
command: node /var/lib/react/express_react_example/server.js &
# command: pm2 start /var/lib/react/express_react_example/server.js
- debug:
msg: 'yayyyyyyyyyyy app is running'
# when: stop_server.rc == 0
=======
command: forever stopall
- debug:
msg: "server stopped"
......@@ -404,4 +201,3 @@
- debug:
msg: "server started"
when: forever_list.stdout.find('/var/lib/react/express_react_example/server.js') == -1
>>>>>>> 526fcc749ba8644fccb39286d817d314a38308f0
---
- name: check if packages exits
package_facts:
manager: auto
- name: 'install all the dependencies '
tags: always
become: yes
apt:
name: ['nodejs','npm']
state: latest
install_recommends: no
update_cache: yes
- debug:
msg: "node and npm installed"
- name: make sure the latest npm is installed
tags: 'node'
become: yes
npm:
name: npm
global: yes
state: latest
- name: install pm2 server
tags: 'pm2'
become: yes
npm:
name: pm2
global: yes
state: latest
- name: install react
tags: 'react'
become: yes
npm:
name: create-react-app
global: yes
state: present
- name: Checking folders
tags: 'volumes'
become: yes
stat:
path: "{{ item.mountpoint }}"
register: directory_stats
with_items:
- "{{ volumes }}"
- name: Create directory
tags: 'volumes'
become: yes
file:
path: "{{ item.item.mountpoint }}"
recurse: yes
state: directory
when: item.stat.exists == false
with_items:
- "{{ directory_stats.results }}"
- name: Mount device
tags: 'volumes'
become: yes
mount:
path: "{{ item.mountpoint }}"
src: "{{ item.device }}"
fstype: xfs
state: mounted
when: item.device is defined
with_items:
- "{{ volumes }}"
- name: traverse into the project directory.
become: yes
shell: cd
args:
chdir: /var/lib/react
register: dir_changed
- name: clone git repo
become: yes
git:
repo: https://github.com/advait22/react-server.git
dest: /var/lib/react
force: yes
- debug:
msg: 'git repo cloned'
when: dir_changed.rc == 0
- name: change working directory to the app
become: yes
shell: cd
args:
chdir: /var/lib/react/express_react_example
register: server
- name: install all the packages for server
become: yes
npm:
path: /var/lib/react/express_react_example/
name: install
- debug:
msg: 'inside server'
when: server.rc == 0
- name: install dependencies
become: yes
command: npm install --save express
- debug:
msg: 'Client express installed'
when: server.rc == 0
- name: change working directory to the client
become: yes
shell: cd
args:
chdir: /var/lib/react/express_react_example/client
register: client
- name: install dependencies
become: yes
npm:
path: /var/lib/react/express_react_example/client
name: install
- debug:
msg: 'Client Dependencies installed'
when: client.rc == 0
- name: Ansible check directory exists build in client.
stat:
path: /var/lib/react/express_react_example/client/build
register: files_to_delete
- name: delete previous build folder
become: yes
shell: rm -rf build
args:
chdir: /var/lib/react/express_react_example/client/
register: build_delete
- debug:
msg: "build deleted"
when: files_to_delete.stat.exists == true
###workaround for react js bug in build command
- name: delete dependencies on client
become: yes
shell: rm -rf node_modules
args:
chdir: /var/lib/react/express_react_example/client/
register: deleted_modules
- debug:
msg: 'Client Dependencies delete'
- name: clear npm cache
tags: 'clear cache'
become: yes
shell: npm cache clean --force
args:
chdir: /var/lib/react/express_react_example/client
register: cache_cleaned
when: deleted_modules.rc == 0
- name: install dependencies
become: yes
npm:
path: /var/lib/react/express_react_example/client
name: install
- debug:
msg: 'Client Dependencies installed'
when: cache_cleaned.rc == 0
- name: install react scripts
tags: 'react scripts'
become: yes
shell: npm install --save react-scripts@3.0.1 react react-dom
args:
chdir: /var/lib/react/express_react_example/client
register: react_scripts
when: cache_cleaned.rc == 0
#################################################################
- name : compile the new build
tags: build
become: yes
shell: npm run build
args:
chdir: /var/lib/react/express_react_example/client
- debug:
msg: 'new build successfull'
- name: Ansible check directory exists build in server.
stat:
path: /var/lib/react/express_react_example/build
register: files_to_delete_from_server
- name: delete previous build folder in server
become: yes
shell: rm -rf build
args:
chdir: /var/lib/react/express_react_example/
register: build_delete_server
- debug:
msg: "deleting old build from server"
when: files_to_delete_from_server.stat.exists == true
- name: copy new build to parent folder
become: yes
command: mv /var/lib/react/express_react_example/client/build /var/lib/react/express_react_example
register: build_copy
- debug:
msg: 'build copied'
when: build_delete_server.rc == 0
- name: stop all the running server
become: yes
command: pm2 stop all
register: stop_server
- debug:
msg: 'all servers stopped'
# when: build_copy.rc == 0
- name: start the server
become: yes
# command: node /var/lib/react/express_react_example/server.js &
command: pm2 start /var/lib/react/express_react_example/server.js
- debug:
msg: 'yayyyyyyyyyyy app is running'
# when: stop_server.rc == 0
\ No newline at end of file
This diff is collapsed.
_design/language
\ No newline at end of file
javascript
\ No newline at end of file
function (head, req) {
provides("json", function() {
send('{"type" : "FeatureCollection", "features" : [');
var sep="";
while (row = getRow()) {
if (row.doc.coordinates) {
var feat = {
type: "Feature",
geometry: {
type: "Point",
coordinates: row.doc.coordinates.coordinates
},
properties: {
text: row.doc.text,
user: row.doc.user.screen_name
}
};
send(sep + JSON.stringify(feat));
sep = ",";
}
}
send("]}");
});
}
function (head, req) {
provides("json", function() {
send('{"type" : "FeatureCollection", "features" : [');
var sep="";
while (row = getRow()) {
if (row.doc.coordinates) {
var feat = {
type: "Feature",
geometry: {
type: "Point",
coordinates: row.doc.coordinates.coordinates
},
properties: {
text: row.doc.text,
user: row.doc.user.screen_name
}
};
send(sep + JSON.stringify(feat));
sep = ",";
}
}
send("]}");
});
}
(head, req) => {
provides("html", () => {
send(`<table border="2">`);
var row;
while (row = getRow()) {
send(`<tr><td>${JSON.stringify(row.key)}</td><td><td>${JSON.stringify(row.value)}</td></tr>`);
}
send(`</table>`);
});
}
(head, req) => {
provides("html", () => {
send(`<table border="2">`);
var row;
while (row = getRow()) {
send(`<tr><td>${JSON.stringify(row.key)}</td><td><td>${JSON.stringify(row.value)}</td></tr>`);
}
send(`</table>`);
});
}
(doc, req) => {
if (doc) {
let bold = (req.query.bold) ? '<b>' : '';
return `<h2> ${doc.user.screen_name}</h2><p>${bold}${doc.text}</p>`;
} else {
return `<h2>No document found<>h2/>`;
}
}
(doc, req) => {
if (doc) {
let bold = (req.query.bold) ? '<b>' : '';
return `<h2> ${doc.user.screen_name}</h2><p>${bold}${doc.text}</p>`;
} else {
return `<h2>No document found<>h2/>`;
}
}
function (doc) {
emit([doc.user.lang], 1);
}
\ No newline at end of file
function (doc) {
emit([doc.user.lang], 1);
}
\ No newline at end of file
_stats
\ No newline at end of file
_stats
\ No newline at end of file
function (doc) {
var lib = require("views/lib/lib");
emit([lib.languageFamily(doc.user.lang), doc.user.lang], 1);
}
\ No newline at end of file
function (doc) {
var lib = require("views/lib/lib");
emit([lib.languageFamily(doc.user.lang), doc.user.lang], 1);
}
\ No newline at end of file
_stats
\ No newline at end of file
_stats
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment