Last active
September 8, 2022 01:03
-
-
Save tatsuyasusukida/dc5a008f84860ca43bdc82e94eed1366 to your computer and use it in GitHub Desktop.
π How to avoid "Container terminated due to sandbox error" in Cloud Run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http') | |
main() | |
function main () { | |
const server = http.createServer() | |
server.on('request', (_, res) => { | |
const content = 'main.js' | |
res.writeHead(200, { | |
'Content-Type': 'text/plain', | |
'Content-Length': content.length, | |
}) | |
res.write(content) | |
res.end() | |
}) | |
server.on('error', (err) => { | |
console.error(err) | |
}) | |
server.listen(process.env.PORT) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http') | |
if (require.main === module) { | |
main() | |
} | |
function main () { | |
const server = http.createServer() | |
server.on('request', (_, res) => { | |
const content = 'main.js' | |
res.writeHead(200, { | |
'Content-Type': 'text/plain', | |
'Content-Length': content.length, | |
}) | |
res.write(content) | |
res.end() | |
}) | |
server.on('error', (err) => { | |
console.error(err) | |
}) | |
server.listen(process.env.PORT) | |
} | |
module.exports = main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http') | |
if (require.main === module) { | |
main() | |
} | |
function main () { | |
const server = http.createServer() | |
server.on('request', (_, res) => { | |
const content = 'sub.js' | |
res.writeHead(200, { | |
'Content-Type': 'text/plain', | |
'Content-Length': content.length, | |
}) | |
res.write(content) | |
res.end() | |
}) | |
server.on('error', (err) => { | |
console.error(err) | |
}) | |
server.listen(process.env.PORT) | |
} | |
module.exports = main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const scriptMain = require('./script-main') | |
const scriptSub = require('./script-sub') | |
main() | |
function main () { | |
if (process.env.SCRIPT === 'main.js') { | |
scriptMain() | |
} else if (process.env.SCRIPT === 'sub.js') { | |
scriptSub() | |
} else { | |
throw new TypeError(`invalid SCRIPT env: ${process.env.SCRIPT}`) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http') | |
main() | |
function main () { | |
const server = http.createServer() | |
server.on('request', (_, res) => { | |
const content = 'sub.js' | |
res.writeHead(200, { | |
'Content-Type': 'text/plain', | |
'Content-Length': content.length, | |
}) | |
res.write(content) | |
res.end() | |
}) | |
server.on('error', (err) => { | |
console.error(err) | |
}) | |
server.listen(process.env.PORT) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment