Skip to content

Commit

Permalink
Merge branch 'release/react' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Feb 19, 2019
2 parents b8b6e3e + e792a98 commit b967d36
Show file tree
Hide file tree
Showing 319 changed files with 87,655 additions and 35,706 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["@babel/react", "@babel/env"]
"presets": ["@babel/react", "@babel/env"],
"plugins": [["@babel/plugin-proposal-decorators", {}], ["@babel/plugin-proposal-class-properties", {}]]
}
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extends": ["standard", "prettier", "prettier/standard"],
"root": true,
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 2015
},
"env": {
"browser": true,
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ config.json
import.csv
/src/mailer/templates/promo/
*.pem
/public/js/
/public/uploads/tickets/
/public/uploads/users/
coverage.html
Expand Down
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:10.10-alpine

RUN mkdir -p /usr/src/trudesk
WORKDIR /usr/src/trudesk

COPY . /usr/src/trudesk

RUN apk add --no-cache --update bash make gcc g++ python mongodb-tools

RUN npm install -g yarn && \
yarn install --production=false --prefer-offline && \
npm rebuild bcrypt node-sass --build-from-source && \
yarn run build && \
yarn install --production --prefer-offline && \
apk del make gcc g++ python

EXPOSE 8118

CMD [ "/bin/bash", "/usr/src/trudesk/startup.sh" ]
102 changes: 63 additions & 39 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
========================================================================
**/

var _ = require('lodash')
var async = require('async')
var path = require('path')
var fs = require('fs')
Expand All @@ -19,6 +20,8 @@ var pkg = require('./package.json')
var ws = require('./src/webserver')
// `var memory = require('./src/memory');

var isDocker = process.env.TRUDESK_DOCKER || false

global.forks = []

nconf.argv().env()
Expand Down Expand Up @@ -84,7 +87,6 @@ if (!process.env.FORK) {
}

var configFile = path.join(__dirname, '/config.json')

var configExists

if (nconf.get('config')) {
Expand All @@ -93,33 +95,14 @@ if (nconf.get('config')) {

configExists = fs.existsSync(configFile)

if (process.env.HEROKU) {
// Build Config for Heroku
var configHeroku = {
url: 'http://localhost:8118',
port: '8118'
}

winston.info('Creating heroku config file...')
var config = JSON.stringify(configHeroku, null, 4)

if (configExists) {
fs.unlinkSync(configFile)
}

fs.writeFileSync(configFile, config)

start()
}

if (nconf.get('install') || (!configExists && !process.env.HEROKU)) {
function launchInstallServer () {
ws.installServer(function () {
return winston.info('Trudesk Install Server Running...')
})
}

if (!nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && !nconf.get('reset') && configExists) {
start()
if (nconf.get('install') || (!configExists && !isDocker)) {
launchInstallServer()
}

function loadConfig () {
Expand All @@ -133,7 +116,7 @@ function loadConfig () {
}

function start () {
loadConfig()
if (!isDocker) loadConfig()

var _db = require('./src/database')

Expand All @@ -150,11 +133,7 @@ function start () {
})
}

function dbCallback (err, db) {
if (err) {
return start()
}

function launchServer (db) {
ws.init(db, function (err) {
if (err) {
winston.error(err)
Expand All @@ -163,6 +142,12 @@ function dbCallback (err, db) {

async.series(
[
function (next) {
require('./src/settings/defaults').init(next)
},
function (next) {
require('./src/permissions').register(next)
},
function (next) {
require('./src/socketserver')(ws)
return next()
Expand All @@ -184,23 +169,23 @@ function dbCallback (err, db) {
winston.debug('Starting MailCheck...')
mailCheck.init(settings)
})
} else {
return next()
}

return next()
})
},
function (next) {
require('./src/settings/defaults').init(next)
require('./src/migration').run(next)
},
function (next) {
winston.debug('Building dynamic sass...')
require('./src/sass/buildsass').build(next)
},
function (next) {
// Start Task Runners
require('./src/taskrunner')
return next()
},
// function (next) {
// // Start Task Runners
// require('./src/taskrunner')
// return next()
// },
function (next) {
// var pm2 = require('pm2');
// pm2.connect(true, function(err) {
Expand Down Expand Up @@ -237,9 +222,23 @@ function dbCallback (err, db) {
if (process.env.MEMORYLIMIT) {
memLimit = process.env.MEMORYLIMIT
}

var env = { FORK: 1, NODE_ENV: global.env }
if (isDocker) {
var envDocker = {
TD_MONGODB_SERVER: process.env.TD_MONGODB_SERVER,
TD_MONGODB_PORT: process.env.TD_MONGODB_PORT,
TD_MONGODB_USERNAME: process.env.TD_MONGODB_USERNAME,
TD_MONGODB_PASSWORD: process.env.TD_MONGODB_PASSWORD,
TD_MONGODB_DATABASE: process.env.TD_MONGODB_DATABASE
}

env = _.merge(env, envDocker)
}

var n = fork(path.join(__dirname, '/src/cache/index.js'), {
execArgv: ['--max-old-space-size=' + memLimit],
env: { FORK: 1, NODE_ENV: global.env }
env: env
})

global.forks.push({ name: 'cache', fork: n })
Expand All @@ -258,8 +257,33 @@ function dbCallback (err, db) {
}
],
function () {
winston.info('trudesk Ready')
ws.listen(function () {
winston.info('trudesk Ready')
})
}
)
})
}

function dbCallback (err, db) {
if (err) {
return start()
}

if (isDocker) {
var s = require('./src/models/setting')
s.getSettingByName('installed', function (err, installed) {
if (err) return start()

if (!installed) {
return launchInstallServer()
} else {
return launchServer(db)
}
})
} else {
return launchServer(db)
}
}

if (!nconf.get('install') && (configExists || isDocker)) start()
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (grunt) {

watch: {
web: {
files: ['*.js', 'src/**/*.js', 'plugins/**/*.js', '!src/public/**/*.js'],
files: ['*.js', 'src/**/*.js', 'plugins/**/*.js', '!src/public/**/*.js', '!src/client/**/*.js'],
tasks: ['express:web'],
options: {
nospawn: true,
Expand Down
2 changes: 1 addition & 1 deletion mobile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<div class="mobile-container">


<!--<div id="loader" class="loader"></div>-->
<div id="loader" class="loader"></div>
<ion-nav-bar class="bar-dark nav-title-slide-ios7">
<ion-nav-back-button>
</ion-nav-back-button>
Expand Down
Loading

0 comments on commit b967d36

Please sign in to comment.