mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-09 14:33:44 +08:00
rm(aws-sdk): Ship logs via request
, eliminate aws-sdk
This commit is contained in:
parent
848fa10dee
commit
43a61d2471
4 changed files with 20 additions and 33 deletions
|
@ -13,7 +13,6 @@ module.exports = (grunt) ->
|
|||
'**/vendor/**'
|
||||
'**/examples/**'
|
||||
'**/src/tasks/**'
|
||||
'**/node_modules/aws-sdk/**'
|
||||
'**/node_modules/spellchecker/**'
|
||||
]
|
||||
unpack = "{#{unpack.join(',')}}"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
"asar": "^0.5.0",
|
||||
"async": "^0.9",
|
||||
"atom-keymap": "^5.1",
|
||||
"aws-sdk": "2.1.28",
|
||||
"bluebird": "^2.9",
|
||||
"classnames": "1.2.1",
|
||||
"clear-cut": "0.4.0",
|
||||
|
|
|
@ -20,7 +20,7 @@ var logpid = process.pid;
|
|||
if (process.type === 'renderer') {
|
||||
logpid = remote.process.pid + "." + process.pid;
|
||||
}
|
||||
var logpath = path.join(tmpPath, 'edgehill-' + logpid + '.log');
|
||||
var logpath = path.join(tmpPath, 'Nylas-N1-' + logpid + '.log');
|
||||
|
||||
// globally define Error.toJSON. This allows us to pass errors via IPC
|
||||
// and through the Action Bridge. Note:they are not re-inflated into
|
||||
|
@ -78,7 +78,7 @@ module.exports = ErrorReporter = (function() {
|
|||
return;
|
||||
}
|
||||
|
||||
var logFilter = new RegExp("edgehill-[.0-9]*.log$");
|
||||
var logFilter = new RegExp("Nylas-N1-[.0-9]*.log$");
|
||||
files.forEach(function(file) {
|
||||
if (logFilter.test(file) === true) {
|
||||
var filepath = path.join(tmpPath, file);
|
||||
|
@ -239,9 +239,9 @@ module.exports = ErrorReporter = (function() {
|
|||
}
|
||||
var logPattern = null;
|
||||
if (process.type === 'renderer') {
|
||||
logPattern = "edgehill-"+remote.process.pid+"[.0-9]*.log$";
|
||||
logPattern = "Nylas-N1-"+remote.process.pid+"[.0-9]*.log$";
|
||||
} else {
|
||||
logPattern = "edgehill-"+process.pid+"[.0-9]*.log$";
|
||||
logPattern = "Nylas-N1-"+process.pid+"[.0-9]*.log$";
|
||||
}
|
||||
|
||||
console.log("ErrorReporter: Shipping Logs. " + reason);
|
||||
|
|
|
@ -2,7 +2,7 @@ fs = require 'fs'
|
|||
path = require 'path'
|
||||
request = require 'request'
|
||||
|
||||
detailedLogging = false
|
||||
detailedLogging = true
|
||||
detailedLog = (msg) ->
|
||||
console.log(msg) if detailedLogging
|
||||
|
||||
|
@ -32,34 +32,23 @@ module.exports = (dir, regexPattern) ->
|
|||
callback()
|
||||
return
|
||||
|
||||
# The AWS Module does some really interesting stuff - it loads it's configuration
|
||||
# from JSON files. Unfortunately, when the app is built into an ASAR bundle, child
|
||||
# processes forked from the main process can't seem to access files inside the archive,
|
||||
# so AWS can't find it's JSON config. (5/20)
|
||||
if __dirname.indexOf('app.asar') != -1
|
||||
AWSModulePath = path.join(__dirname, '..','..','..', 'app.asar.unpacked', 'node_modules', 'aws-sdk')
|
||||
else
|
||||
AWSModulePath = 'aws-sdk'
|
||||
|
||||
# Note: These credentials are only good for uploading to this
|
||||
# specific bucket and can't be used for anything else.
|
||||
AWS = require(AWSModulePath)
|
||||
AWS.config.update
|
||||
accessKeyId: 'AKIAIEGVDSVLK3Z7UVFA',
|
||||
secretAccessKey: '5ZNFMrjO3VUxpw4F9Y5xXPtVHgriwiWof4sFEsjQ'
|
||||
|
||||
bucket = new AWS.S3({params: {Bucket: 'edgehill-client-logs'}})
|
||||
uploadTime = Date.now()
|
||||
|
||||
logs.forEach (log) ->
|
||||
stream = fs.createReadStream(log, {flags: 'r'})
|
||||
key = "#{uploadTime}-#{path.basename(log)}"
|
||||
params = {Key: key, Body: stream}
|
||||
remaining += 1
|
||||
bucket.upload params, (err, data) ->
|
||||
url = 'https://edgehill.nylas.com/ingest-log'
|
||||
formData =
|
||||
file:
|
||||
value: fs.createReadStream(log, {flags: 'r'})
|
||||
options:
|
||||
filename: 'log.txt',
|
||||
contentType: 'text/plain'
|
||||
|
||||
request.post {url, formData}, (err, response, body) ->
|
||||
if err
|
||||
detailedLog("Error uploading #{key}: #{err.toString()}")
|
||||
detailedLog("Error uploading #{log}: #{err.toString()}")
|
||||
else if response.statusCode isnt 200
|
||||
detailedLog("Error uploading #{log}: status code #{response.statusCode}")
|
||||
else
|
||||
detailedLog("Successfully uploaded #{key}")
|
||||
fs.truncate(log)
|
||||
detailedLog("Successfully uploaded #{log}")
|
||||
fs.truncate log, =>
|
||||
fs.unlink(log)
|
||||
finished()
|
||||
|
|
Loading…
Reference in a new issue