fix: daemon not launching on Windows #1101
5 changed files with 103 additions and 39 deletions
29
build/checkDaemonPlatform.js
Normal file
29
build/checkDaemonPlatform.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* eslint-disable no-console,import/no-extraneous-dependencies,import/no-commonjs */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This script is necessary for checking that the daemon that has been downloaded during the
|
||||||
|
* yarn installing process is the one for the building target. For example, on Travis the
|
||||||
|
* Windows package is built on Linux, thus yarn will download the daemon for Linux instead of
|
||||||
|
* Windows. The script will test that and then download the right daemon for the targeted platform.
|
||||||
|
*/
|
||||||
|
const os = require('os');
|
||||||
|
const downloadDaemon = require('./downloadDaemon');
|
||||||
|
|
||||||
|
module.exports = context => {
|
||||||
|
|
||||||
|
let currentPlatform = os.platform();
|
||||||
|
if (currentPlatform === 'darwin') currentPlatform = 'macoss';
|
||||||
|
if (currentPlatform === 'win32') currentPlatform = 'windows';
|
||||||
|
|
||||||
|
let buildingPlatformTarget = context.platform.toString();
|
||||||
|
if (buildingPlatformTarget === 'mac') buildingPlatformTarget = 'macos';
|
||||||
|
|
||||||
|
if (buildingPlatformTarget !== currentPlatform) {
|
||||||
|
console.log(
|
||||||
|
"\x1b[34minfo\x1b[0m Daemon platform doesn't match target platform. Redownloading the daemon."
|
||||||
|
);
|
||||||
|
|
||||||
|
return downloadDaemon(buildingPlatformTarget);
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
|
@ -1,47 +1,70 @@
|
||||||
/* eslint-disable no-console,import/no-commonjs */
|
/* eslint-disable no-console,import/no-extraneous-dependencies,import/no-commonjs */
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const packageJSON = require('../package.json');
|
const packageJSON = require('../package.json');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
||||||
const decompress = require('decompress');
|
const decompress = require('decompress');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const del = require('del');
|
||||||
|
|
||||||
const daemonURLTemplate = packageJSON.lbrySettings.lbrynetDaemonUrlTemplate;
|
const downloadDaemon = targetPlatform =>
|
||||||
const daemonVersion = packageJSON.lbrySettings.lbrynetDaemonVersion;
|
new Promise((resolve, reject) => {
|
||||||
let currentPlatform = os.platform();
|
const daemonURLTemplate = packageJSON.lbrySettings.lbrynetDaemonUrlTemplate;
|
||||||
if (currentPlatform === 'darwin') currentPlatform = 'macos';
|
const daemonVersion = packageJSON.lbrySettings.lbrynetDaemonVersion;
|
||||||
if (currentPlatform === 'win32') currentPlatform = 'windows';
|
const daemonDir = packageJSON.lbrySettings.lbrynetDaemonDir;
|
||||||
|
const daemonFileName = packageJSON.lbrySettings.lbrynetDaemonFileName;
|
||||||
|
|
||||||
const daemonURL = daemonURLTemplate
|
let currentPlatform = os.platform();
|
||||||
.replace(/DAEMONVER/g, daemonVersion)
|
if (currentPlatform === 'darwin') currentPlatform = 'macos';
|
||||||
.replace(/OSNAME/g, currentPlatform);
|
if (currentPlatform === 'win32') currentPlatform = 'windows';
|
||||||
const tmpZipPath = 'build/daemon.zip';
|
|
||||||
|
|
||||||
console.log('\x1b[34minfo\x1b[0m Downloading daemon...');
|
const daemonPlatform = targetPlatform || currentPlatform;
|
||||||
axios
|
|
||||||
.request({
|
const daemonURL = daemonURLTemplate
|
||||||
responseType: 'arraybuffer',
|
.replace(/DAEMONVER/g, daemonVersion)
|
||||||
url: daemonURL,
|
.replace(/OSNAME/g, daemonPlatform);
|
||||||
method: 'get',
|
const tmpZipPath = 'build/daemon.zip';
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/zip',
|
console.log('\x1b[34minfo\x1b[0m Downloading daemon...');
|
||||||
},
|
axios
|
||||||
})
|
.request({
|
||||||
.then(result => {
|
responseType: 'arraybuffer',
|
||||||
fs.writeFileSync(tmpZipPath, result.data);
|
url: daemonURL,
|
||||||
return true;
|
method: 'get',
|
||||||
})
|
headers: {
|
||||||
.then(() => {
|
'Content-Type': 'application/zip',
|
||||||
decompress(tmpZipPath, 'static/daemon', {
|
},
|
||||||
filter: file =>
|
})
|
||||||
path.basename(file.path).replace(path.extname(file.path), '') === 'lbrynet-daemon',
|
.then(
|
||||||
});
|
result =>
|
||||||
})
|
new Promise((newResolve, newReject) => {
|
||||||
.then(() => {
|
fs.writeFile(tmpZipPath, result.data, error => {
|
||||||
console.log('\x1b[32msuccess\x1b[0m Daemon downloaded!');
|
if (error) return newReject(error);
|
||||||
})
|
return newResolve();
|
||||||
.catch(error => {
|
});
|
||||||
console.error(`\x1b[31merror\x1b[0m Daemon download failed due to: \x1b[35m${error}\x1b[0m`);
|
})
|
||||||
|
)
|
||||||
|
.then(() => del(`${daemonDir}/${daemonFileName}*`))
|
||||||
|
.then(() =>
|
||||||
|
decompress(tmpZipPath, daemonDir, {
|
||||||
|
filter: file =>
|
||||||
|
path.basename(file.path).replace(path.extname(file.path), '') === daemonFileName,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
console.log('\x1b[32msuccess\x1b[0m Daemon downloaded!');
|
||||||
|
resolve(true);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(
|
||||||
|
`\x1b[31merror\x1b[0m Daemon download failed due to: \x1b[35m${error}\x1b[0m`
|
||||||
|
);
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
module.exports = downloadDaemon;
|
||||||
|
|
||||||
|
require('make-runnable/custom')({
|
||||||
|
printOutputFrame: false
|
||||||
|
});
|
||||||
|
|
|
@ -50,5 +50,6 @@
|
||||||
"nsis": {
|
"nsis": {
|
||||||
"perMachine": true
|
"perMachine": true
|
||||||
},
|
},
|
||||||
|
"beforeBuild": "./build/checkDaemonPlatform.js",
|
||||||
"artifactName": "${productName}_${version}.${ext}"
|
"artifactName": "${productName}_${version}.${ext}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
"babel-preset-react": "^6.24.1",
|
"babel-preset-react": "^6.24.1",
|
||||||
"babel-preset-stage-2": "^6.18.0",
|
"babel-preset-stage-2": "^6.18.0",
|
||||||
"decompress": "^4.2.0",
|
"decompress": "^4.2.0",
|
||||||
|
"del": "^3.0.0",
|
||||||
"devtron": "^1.4.0",
|
"devtron": "^1.4.0",
|
||||||
"electron": "1.7.10",
|
"electron": "1.7.10",
|
||||||
"electron-builder": "^20.3.1",
|
"electron-builder": "^20.3.1",
|
||||||
|
@ -103,6 +104,7 @@
|
||||||
"i18n-extract": "^0.5.1",
|
"i18n-extract": "^0.5.1",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lint-staged": "^7.0.0",
|
"lint-staged": "^7.0.0",
|
||||||
|
"make-runnable": "^1.3.6",
|
||||||
"node-loader": "^0.6.0",
|
"node-loader": "^0.6.0",
|
||||||
"node-sass": "^4.7.2",
|
"node-sass": "^4.7.2",
|
||||||
"prettier": "^1.11.1",
|
"prettier": "^1.11.1",
|
||||||
|
@ -117,6 +119,8 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"lbrySettings": {
|
"lbrySettings": {
|
||||||
"lbrynetDaemonVersion": "0.19.0",
|
"lbrynetDaemonVersion": "0.19.0",
|
||||||
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip"
|
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip",
|
||||||
|
"lbrynetDaemonDir": "static/daemon",
|
||||||
|
"lbrynetDaemonFileName": "lbrynet-daemon"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6170,6 +6170,13 @@ make-fetch-happen@^2.4.13, make-fetch-happen@^2.5.0:
|
||||||
socks-proxy-agent "^3.0.1"
|
socks-proxy-agent "^3.0.1"
|
||||||
ssri "^5.0.0"
|
ssri "^5.0.0"
|
||||||
|
|
||||||
|
make-runnable@^1.3.6:
|
||||||
|
version "1.3.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/make-runnable/-/make-runnable-1.3.6.tgz#ca9b1d31b06f051e37570fb7ad98bc5369f982be"
|
||||||
|
dependencies:
|
||||||
|
bluebird "^3.5.0"
|
||||||
|
yargs "^4.7.1"
|
||||||
|
|
||||||
map-cache@^0.2.2:
|
map-cache@^0.2.2:
|
||||||
version "0.2.2"
|
version "0.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
|
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
|
||||||
|
@ -10480,7 +10487,7 @@ yargs@^11.0.0:
|
||||||
y18n "^3.2.1"
|
y18n "^3.2.1"
|
||||||
yargs-parser "^9.0.2"
|
yargs-parser "^9.0.2"
|
||||||
|
|
||||||
yargs@^4.2.0:
|
yargs@^4.2.0, yargs@^4.7.1:
|
||||||
version "4.8.1"
|
version "4.8.1"
|
||||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0"
|
resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
Loading…
Reference in a new issue