Skip to content

Commit cd799c5

Browse files
committed
made workers stand alone, fixed dockerfiles for clock and the app and added the docker file for workers, added loggly support, added mongodb 3.6 support, better error handling, updated templates
1 parent 2aabaf4 commit cd799c5

File tree

24 files changed

+301
-267
lines changed

24 files changed

+301
-267
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jspm_packages
3535

3636
# Optional REPL history
3737
.node_repl_history
38+
39+
#Mac
40+
.DS_Store

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ FROM node:carbon
22

33
WORKDIR /usr/src/app
44

5-
COPY ../package*.json ./
5+
COPY package*.json ./
66

77
RUN npm install
88

99
COPY . .
1010

11-
CMD [ "npm", "run", "clock" ]
11+
EXPOSE 8080
12+
13+
CMD [ "npm", "start" ]

app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ if (cluster.isMaster && config.env === 'production') {
3535
var app = express();
3636
var router = require('./routes');
3737
var express_enforces_ssl = require('express-enforces-ssl');
38-
var workers = require('./services/queue/workers');
3938

4039
if(config.trustProxy === 'yes'){
4140
app.enable('trust proxy');

clock/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM node:carbon
22

33
WORKDIR /usr/src/app
44

5-
COPY ../package*.json ./
5+
COPY ./package*.json ./
66

77
RUN npm install
88

config/development.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,10 @@ module.exports = {
3030
SQLHost: process.env.SQL_HOST || '192.168.99.100',
3131
SQLPort: process.env.SQL_PORT || 3306,
3232
SQLDriver: process.env.SQL_DRIVER || 'mysql', //'mysql'|'sqlite'|'postgres'|'mssql'
33-
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00'
33+
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00',
34+
clockTimezone: process.env.CLOCK_TIMEZONE || 'Africa/Lagos',
35+
workerConcurrency: process.env.WORKER_CONCURRENCY || '1',
36+
logglyToken: process.env.LOGGLY_TOKEN || false,
37+
logglySubdomain: process.env.LOGGLY_SUBDOMAIN || false,
38+
logglyTag: process.env.LOGGLY_TAG || false
3439
};

config/production.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ module.exports = {
2727
SQLUsername: process.env.SQL_USERNAME || 'root',
2828
SQLPassword: process.env.SQL_PASSWORD || null,
2929
SQLDatabase: process.env.SQL_DATABASE || 'snipe',
30-
SQLHost: process.env.SQL_HOST || 'localhost',
30+
SQLHost: process.env.SQL_HOST || '192.168.99.100',
3131
SQLPort: process.env.SQL_PORT || 3306,
3232
SQLDriver: process.env.SQL_DRIVER || 'mysql', //'mysql'|'sqlite'|'postgres'|'mssql'
33-
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00'
33+
SQLTimezone: process.env.SQL_TIMEZONE || '+01:00',
34+
clockTimezone: process.env.CLOCK_TIMEZONE || 'Africa/Lagos',
35+
workerConcurrency: process.env.WORKER_CONCURRENCY || '1',
36+
logglyToken: process.env.LOGGLY_TOKEN || false,
37+
logglySubdomain: process.env.LOGGLY_SUBDOMAIN || false,
38+
logglyTag: process.env.LOGGLY_TAG || false
3439
};

models/RequestLogs.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ var schemaObject = {
4949

5050
schemaObject.createdAt = {
5151
type: 'Date',
52-
default: Date.now
52+
default: Date.now,
53+
index: true
5354
};
5455

5556
schemaObject.updatedAt = {
@@ -59,12 +60,12 @@ schemaObject.updatedAt = {
5960

6061
schemaObject.owner = {
6162
type: db._mongoose.Schema.Types.ObjectId,
62-
ref: 'Users'
63+
ref: 'Accounts'
6364
};
6465

6566
schemaObject.createdBy = {
6667
type: db._mongoose.Schema.Types.ObjectId,
67-
ref: 'Users'
68+
ref: 'Accounts'
6869
};
6970

7071
schemaObject.client = {
@@ -165,20 +166,20 @@ Schema.post('find', function(result) {
165166
Schema.pre('update', function(next) {
166167

167168
// Indexing for search
168-
var ourDoc = this._update.$set;
169-
debug('What we are updating: ', ourDoc);
170-
ourDoc.model = collection;
171-
ourDoc.update = true;
172-
debug('what do we have here: ', ourDoc);
173-
if(ourDoc.updatedAt || ourDoc.tags){
174-
debug('updatedAt: ', ourDoc.updatedAt);
175-
debug('tags: ', ourDoc.tags);
176-
// Move along! Nothing to see here!!
177-
}else{
178-
// Dump it in the queue
179-
queue.create('searchIndex', ourDoc)
180-
.save();
181-
}
169+
var ourDoc = this._update;
170+
// debug('What we are updating: ', ourDoc);
171+
// ourDoc.model = collection;
172+
// ourDoc.update = true;
173+
// debug('what do we have here: ', ourDoc);
174+
// if(ourDoc.updatedAt || ourDoc.tags){
175+
// debug('updatedAt: ', ourDoc.updatedAt);
176+
// debug('tags: ', ourDoc.tags);
177+
// // Move along! Nothing to see here!!
178+
// }else{
179+
// // Dump it in the queue
180+
// queue.create('searchIndex', ourDoc)
181+
// .save();
182+
// }
182183
ourDoc.updatedAt = new Date(Date.now()).toISOString();
183184
next();
184185
});

models/Trash.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ var schemaObject = {
2222

2323
schemaObject.createdAt = {
2424
type: 'Date',
25-
default: Date.now
25+
default: Date.now,
26+
index: true
2627
};
2728

2829
schemaObject.updatedAt = {
@@ -32,12 +33,12 @@ schemaObject.updatedAt = {
3233

3334
schemaObject.owner = {
3435
type: db._mongoose.Schema.Types.ObjectId,
35-
ref: 'Users'
36+
ref: 'Accounts'
3637
};
3738

3839
schemaObject.deletedBy = {
3940
type: db._mongoose.Schema.Types.ObjectId,
40-
ref: 'Users'
41+
ref: 'Accounts'
4142
};
4243

4344
schemaObject.client = {
@@ -137,7 +138,7 @@ Schema.post('find', function(result) {
137138

138139
Schema.pre('update', function(next) {
139140
// Indexing for search
140-
var ourDoc = this._update.$set;
141+
var ourDoc = this._update;
141142
ourDoc.model = collection;
142143
ourDoc.update = true;
143144

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"test": "gulp sanity",
88
"start": "node app",
9-
"clock": "node ./services/queue/clock"
9+
"clock": "node ./services/queue/clock",
10+
"workers": "node ./services/queue/workers"
1011
},
1112
"repository": {
1213
"type": "git",
@@ -68,7 +69,7 @@
6869
"hpp": "^0.2.2",
6970
"kue": "^0.11.6",
7071
"lodash": "^4.17.4",
71-
"mongoose": "^4.9.0",
72+
"mongoose": "^5.0.0",
7273
"mysql2": "^1.5.1",
7374
"pg": "^6.4.2",
7475
"pg-hstore": "^2.3.2",
@@ -78,10 +79,12 @@
7879
"request": "^2.83.0",
7980
"request-promise": "^4.2.1",
8081
"sequelize": "^4.28.6",
82+
"shortid": "^2.2.8",
8183
"sqlite3": "^3.1.13",
8284
"tedious": "^2.1.5",
8385
"util": "^0.10.3",
8486
"winston": "^2.3.1",
85-
"winston-bugsnag": "^2.1.0"
87+
"winston-bugsnag": "^2.1.0",
88+
"winston-loggly-bulk": "^2.0.2"
8689
}
8790
}

0 commit comments

Comments
 (0)