Xcode Server application Continuation of life
Environments:
- node: 12.8.0
- How to check the xcode server nodejs version? check the file in
/Node/bin/node -v
- How to check the xcode server nodejs version? check the file in
- python: 2.7.16
- Install environment manager tools. You can find by homebrew
- nvm
- pyenv
nvm install 12.8.0
pyenv install 2.7.16
cd xcsd/
pathnpm list
, will sell the issues by ws & Node.js module, and remove it.- Fix the log issues(npm ERR!),
npm install bufferutil@4.0.1 utf-8-validate@5.0.2
npm update
, if you fail, check your node version and python version.npm list
try again, and fix it. Still you will see the log is clean.
Your have two ways to collect the nodejs log.
npm install winston@2
in xcs/xcsd/ path.
Have some information by custom log format with datadog.
{"level":"info","message":"Hello simple log!","timestamp":"2015-04-23T16:52:05.337Z"}
{"color":"blue","level":"info","message":"Hello log with metas","timestamp":"2015-04-23T16:52:05.339Z"}
when you install Datadog integration with nodejs by Datadog guidelines will fail. The reason is dd-trace need bind with xcs environment, and more nodejs run detail check the file(com.apple.xcsd.plist).
- Install dd-trace version, you need check the xcode server nodejs version, and install the same version of dd-trace.
- How to use the same version of dd-trace? dd-trace Version Release Lines and Maintenance
- Install dd-trace of Node.js
npm install dd-trace@2
npm list
, will sell the issues by ws & Node.js module, and remove it.- Flow the Datadog Node.js Tracer to install the dd-trace
Insert the code in the first line of your app.js
// This line must come before importing any instrumented module.
const tracer = require('dd-trace').init({
env: 'xcs-node',
service: 'xcs-app',
logInjection: true
});
Insert the code in the last line of your worker.js
// This line must come after importing any instrumented module.
const tracer = require('dd-trace').init({
env: 'xcs-node',
service: 'xcs-worker',
logInjection: true
});
Upgrade logger with DataDog requirement.
Insert formatMessage function of logger.js
```JavaScript
function formatMessage(level, message) {
switch (level) {
case 2:
level = 'CRITICAL';
break;
case 3:
level = 'ERROR';
break;
case 4:
level = 'WARNING';
break;
case 6:
level = 'INFO';
break;
case 7:
level = 'DEBUG';
break;
default:
level = 'UNKNOWN';
break;
}
const time = new Date().toISOString();
const record = { time, level, message };
return JSON.stringify(record);
}
Upgrade and inset trace segment of logger.js
Logger.prototype.logMessage = function (level) {
var messageArgs = Array.prototype.slice.call(arguments, 1),
message = messageArgs.map(logify).join(' ');
// evaughan TODO: Only log warnings, errors, and critical messages (i.e. skip debug and info messages)
if (level <= 7) {
const jsonMessage = formatMessage(level, message);
const tracer = global.tracer;
const span = tracer.scope().active();
if (span) {
tracer.inject(span.context(), formats.LOG, jsonMessage);
}
console.log('%s', jsonMessage);
// Log stack traces for any errors in the arguments
messageArgs.forEach(arg => {
if (arg && arg.stack) {
const jsonStack = formatMessage(level, arg.stack);
if (span) {
tracer.inject(span.context(), formats.LOG, jsonStack);
}
console.log('%s', jsonStack);
}
});
}
};
nvm install 16
which node
and copy the target to/Node/bin/node
. eg:cp "$(which node)" "${PWD}/../Node/bin/"
.- remove all devDependencies in package.json, Cuz some dev module will fail to install.
npm install dd-trace@4
, The last version of dd-trace is 4 is support this nodejs version.npm list
check the issues and fix it.