Verified Commit ff7a4385 authored by Aral Balkan's avatar Aral Balkan
Browse files

Committing latest attempt before trying something different

parent 34bbb93e
......@@ -32,7 +32,7 @@ async function build () {
input: 'bin/web-server.js',
output: `${linuxVersionPath}/web-server`,
target: 'linux-x64-10.15.3',
resources: ['package.json', 'bin/daemon.js', 'node_modules/pm2/']
resources: ['package.json', 'bin/daemon.js', 'bin/pm2']
})
console.log(' • Building macOS version…')
......
......@@ -9,7 +9,26 @@ const pm2 = require('pm2')
const childProcess = require('child_process')
const arguments = require('minimist')(process.argv.slice(2), {boolean: true})
const pm2Path = path.join(__dirname, '../node_modules/pm2/bin/pm2')
const externalDirectory = path.join(os.homedir(), '.indie-web-server')
if (!fs.existsSync(externalDirectory)) {
try {
fs.mkdirSync(externalDirectory, {recursive: true})
} catch (error) {
console.log(' 💥 Failed to create external directory.', error)
process.exit(1)
}
}
const pm2Path = path.join(externalDirectory, 'pm2')
if (!fs.existsSync(pm2Path)) {
try {
const internalPM2Path = path.join(__dirname, 'pm2')
fs.copyFileSync(internalPM2Path, pm2Path)
} catch (error) {
console.log(' 💥 Failed to copy pm2 binary to external directory.', error)
process.exit(1)
}
}
if (arguments._.length > 2 || arguments.help === true) {
......@@ -222,7 +241,7 @@ if (arguments.live !== undefined) {
}
try {
const output = childProcess.execSync(`sudo ${path.join(__dirname, '../node_modules/pm2/bin/pm2')} startup`, options)
const output = childProcess.execSync(`sudo ${pm2Path} startup`, options)
} catch (error) {
console.log(` 👿 Failed to add server for auto-launch at startup.\n`)
pm2.disconnect()
......
{
"name": "@ind.ie/web-server",
"version": "7.2.1",
"version": "7.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -111,9 +111,9 @@
}
},
"@pm2/agent": {
"version": "0.5.23",
"resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-0.5.23.tgz",
"integrity": "sha512-mviwkRt51y3wY161uxiqXc0wyHTjgo+sIkJ/Mh6m400dYAnAGQ12LFlK56EbnQRwPfPog0q6txqncbFpn4L5zA==",
"version": "0.5.24",
"resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-0.5.24.tgz",
"integrity": "sha512-j6lJMMmGvDvxcyPBO3JpqdSdzlQUlWDSfVRWzLSHKioEUMYeq/JBx3ZQmA1D25OoDPzaymwcquP4B0HR6gU1bQ==",
"requires": {
"async": "^2.6.0",
"chalk": "^2.3.2",
......@@ -1014,9 +1014,9 @@
"integrity": "sha1-bYCcnNDPe7iVLYD8hPoT1H3bEwg="
},
"data-uri-to-buffer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.0.tgz",
"integrity": "sha512-YbKCNLPPP4inc0E5If4OaalBc7gpaM2MRv77Pv2VThVComLKfbGYtJcdDCViDyp1Wd4SebhHLz94vp91zbK6bw==",
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.1.tgz",
"integrity": "sha512-OkVVLrerfAKZlW2ZZ3Ve2y65jgiWqBKsTfUIAFbn8nVbPcCZg6l6gikKlEYv0kXcmzqGm6mFq/Jf2vriuEkv8A==",
"requires": {
"@types/node": "^8.0.7"
}
......@@ -4152,9 +4152,9 @@
}
},
"readable-stream": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.2.0.tgz",
"integrity": "sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw==",
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz",
"integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment