Skip to content

Commit

Permalink
Merge branch 'lf-qa' into lf-live
Browse files Browse the repository at this point in the history
This will become version 1.4.10 of the live LF site.


Former-commit-id: ac295ff
  • Loading branch information
rmunn committed Mar 26, 2018
2 parents c722da6 + 42e6144 commit 5d4abf1
Show file tree
Hide file tree
Showing 95 changed files with 1,949 additions and 1,122 deletions.
120 changes: 109 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
// 'webpack-sf:watch
// 'build-composer'
// 'build-npm-front-end'
// 'build-npm-back-end'
// 'build-webpack'
// 'build-remove-test-fixtures'
// 'build-minify'
Expand Down Expand Up @@ -144,6 +145,20 @@ function getTestCwd(dest) {
return (dest) ? path.join(dest.replace(/^(.)*:/, ''), 'test/app') : './test/app';
}

// Get systemd service suffix from destination
function getServiceSuffix(dest) {
var suffix = '';
var index = dest.indexOf('_');
if (index !== -1) {
suffix = dest.substr(index + 1);
if (suffix.endsWith('/')) {
suffix = suffix.substr(0, suffix.length - 1);
}
suffix = '@' + suffix;
}
return suffix;
}

// Globals
var srcPatterns = [
'src/angular-app/**',
Expand Down Expand Up @@ -508,16 +523,13 @@ gulp.task('local-restart-xforge-web-api', function (cb) {
demand: true,
type: 'string' })
.argv;
var suffix = '';
if (params.dest.includes('e2etest')) {
suffix = '_e2etest';
}

var options = {
applicationName: params.applicationName + suffix
applicationName: params.applicationName,
suffix: getServiceSuffix(params.dest)
};
execute(
'sudo service <%= applicationName %>-web-api restart',
'sudo systemctl restart <%= applicationName %>-web-api<%= suffix %>',
options,
cb
);
Expand All @@ -538,14 +550,80 @@ gulp.task('remote-restart-xforge-web-api', function (cb) {
demand: true,
type: 'string' })
.argv;

var options = {
applicationName: params.applicationName,
credentials: params.uploadCredentials,
destination: params.dest.slice(0, params.dest.indexOf(':'))
destination: params.dest.slice(0, params.dest.indexOf(':')),
suffix: getServiceSuffix(params.dest)
};

execute(
"ssh -i <%= credentials %> <%= destination %> 'systemctl restart <%= applicationName %>-web-api<%= suffix %>'",
options,
cb
);
});

// -------------------------------------
// Task: Local Restart Node Server
// -------------------------------------
gulp.task('local-restart-node-server', function (cb) {
var params = require('yargs')
.option('applicationName', {
demand: true,
type: 'string' })
.option('dest', {
demand: true,
type: 'string' })
.argv;

if (params.applicationName === 'languageforge') {
cb();
return;
}

var options = {
applicationName: params.applicationName,
suffix: getServiceSuffix(params.dest)
};
execute(
'sudo systemctl restart <%= applicationName %>-sharedb<%= suffix %>',
options,
cb
);
});

// -------------------------------------
// Task: Remote Restart Node Server
// -------------------------------------
gulp.task('remote-restart-node-server', function (cb) {
var params = require('yargs')
.option('applicationName', {
demand: true,
type: 'string' })
.option('dest', {
demand: true,
type: 'string' })
.option('uploadCredentials', {
demand: true,
type: 'string' })
.argv;

if (params.applicationName === 'languageforge') {
cb();
return;
}

var options = {
applicationName: params.applicationName,
credentials: params.uploadCredentials,
destination: params.dest.slice(0, params.dest.indexOf(':')),
suffix: getServiceSuffix(params.dest)
};

execute(
"ssh -i <%= credentials %> <%= destination %> 'service <%= applicationName %>-web-api restart'",
"ssh -i <%= credentials %> <%= destination %> 'systemctl restart <%= applicationName %>-sharedb<%= suffix %>'",
options,
cb
);
Expand Down Expand Up @@ -874,6 +952,22 @@ gulp.task('build-npm-front-end', function (cb) {
);
});

// -------------------------------------
// Task: Build npm back-end
// -------------------------------------
gulp.task('build-npm-back-end', function (cb) {
var options = {
dryRun: false,
silent: false,
cwd: 'src/node'
};
execute(
'npm install',
options,
cb
);
});

// -------------------------------------
// Task: Build Remove test fixtures (directives) in HTML only on live build
// -------------------------------------
Expand Down Expand Up @@ -1219,6 +1313,7 @@ gulp.task('build',
gulp.parallel(
'build-composer',
'build-npm-front-end',
'build-npm-back-end',
'build-version',
'build-productionConfig',
'build-clearLocalCache',
Expand All @@ -1233,7 +1328,8 @@ gulp.task('build',
gulp.task('get-dependencies',
gulp.parallel(
'build-composer',
'build-npm-front-end'
'build-npm-front-end',
'build-npm-back-end'
)
);

Expand Down Expand Up @@ -1261,7 +1357,8 @@ gulp.task('build-and-upload',
'build',
'build-upload',
'remote-restart-php-fpm',
'remote-restart-xforge-web-api')
'remote-restart-xforge-web-api',
'remote-restart-node-server')
);

// -------------------------------------
Expand Down Expand Up @@ -1293,7 +1390,8 @@ gulp.task('build-php',
'test-dotnet',
'build-upload',
'test-restart-webserver',
'local-restart-xforge-web-api')
'local-restart-xforge-web-api',
'local-restart-node-server')
);
gulp.task('build-php').description =
'Build and Run PHP tests on CI server; Deploy to dev site';
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json.REMOVED.git-id

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
"angular-zxcvbn": "^3.2.2",
"angularjs-slider": "^6.2.3",
"bootstrap": "4.0.0-beta.2",
"cookie": "^0.3.1",
"core-js": "^2.4.1",
"express": "^4.14.0",
"font-awesome": "^4.7.0",
"intl-tel-input": "9.2.7",
"jquery": "3.1.1",
Expand All @@ -43,10 +41,7 @@
"rangy": "^1.3.0",
"rich-text": "^3.0.1",
"sharedb": "^1.0.0-beta",
"sharedb-mongo": "1.0.0-beta",
"textangular": "1.5.12",
"websocket-json-stream": "^0.0.1",
"ws": "^1.1.0",
"zone.js": "^0.8.16",
"zxcvbn": "^4.4.2"
},
Expand Down
60 changes: 0 additions & 60 deletions scripts/server/init/languageforge-web-api

This file was deleted.

15 changes: 15 additions & 0 deletions scripts/server/init/languageforge-web-api.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Language Forge Web API

[Service]
ExecStartPre=-/bin/rm -f ${SOCKETFILE}
ExecStart=/var/www/languageforge.org/api2/SIL.XForge.WebApi.Server --urls http://unix:${SOCKETFILE}
WorkingDirectory=/var/www/languageforge.org/api2
Restart=always
RestartSec=10
SyslogIdentifier=languageforge-web-api
User=www-data
Environment=SOCKETFILE=/tmp/languageforge-web-api.sock

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions scripts/server/init/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Language Forge Web API (%I)

[Service]
ExecStartPre=-/bin/rm -f ${SOCKETFILE}
ExecStart=/bin/sh -c "exec /var/www/languageforge.org_%i/api2/SIL.XForge.WebApi.Server --urls http://unix:${SOCKETFILE}"
WorkingDirectory=/var/www/languageforge.org_%i/api2
Restart=always
RestartSec=10
SyslogIdentifier=languageforge-web-api_%i
User=www-data
Environment=SOCKETFILE=/tmp/languageforge-web-api_%i.sock

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions scripts/server/init/scriptureforge-sharedb.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Scripture Forge ShareDB Server

[Service]
ExecStart=/usr/local/bin/node /var/www/scriptureforge.org/htdocs/node/server.js
WorkingDirectory=/var/www/scriptureforge.org/htdocs/node
Restart=always
RestartSec=10
SyslogIdentifier=scriptureforge-sharedb
User=root
Group=www-data
Environment=NODE_ENV=production PORT=8443

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions scripts/server/init/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Scripture Forge ShareDB Server (%I)

[Service]
ExecStart=/usr/local/bin/node /var/www/scriptureforge.org_%i/htdocs/node/server.js
WorkingDirectory=/var/www/scriptureforge.org_%i/htdocs/node
Restart=always
RestartSec=10
SyslogIdentifier=scriptureforge-sharedb_%i
User=root
Group=www-data
Environment=NODE_ENV=production PORT=8443

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 5d4abf1

Please sign in to comment.