Skip to content

Commit

Permalink
Add additional debugging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
trappar committed Feb 15, 2024
1 parent 08f9d58 commit 84a75f9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions dist/server/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -240235,8 +240235,10 @@ var __webpack_exports__ = {};
(() => {
const { createApp } = __nccwpck_require__(21968);

console.log('Creating Turbo Cache Server...');
const app = createApp({trustProxy: true});

console.log(`Starting listening for requests on ${process.env.HOST}:${process.env.PORT}...`);
app.listen({ host: process.env.HOST, port: process.env.PORT }, (err) => {
if (err) {
console.error(err);
Expand Down
9 changes: 6 additions & 3 deletions dist/start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6096,7 +6096,7 @@ async function main() {
[(0,external_node_path_namespaceObject.resolve)(start_dirname, '..', 'start_and_log')],
{
detached: true,
stdio: 'ignore',
stdio: 'pipe',
env: {
...process.env,
HOST: host,
Expand All @@ -6108,8 +6108,9 @@ async function main() {
},
);

subprocess.stdout?.on('data', (data) => (0,core.debug)(data.toString()));
subprocess.stderr?.on('data', (data) => (0,core.debug)(data.toString()));
const pid = subprocess.pid?.toString();
subprocess.unref();

try {
(0,core.debug)(`Waiting for port ${port} to be used...`);
Expand All @@ -6123,8 +6124,10 @@ async function main() {
(0,core.exportVariable)('TURBO_API', `http://${host}:${port}`);
(0,core.exportVariable)('TURBO_TOKEN', token);
(0,core.exportVariable)('TURBO_TEAM', teamId);

process.exit(0);
} catch (e) {
throw new Error(`Turbo server failed to start on port: ${port}`);
throw new Error(`Turbo server failed to start on port: ${port}\n${e}`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions dist/start_and_log/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const readLog = async (name) => {

const start_and_log_dirname = (0,external_node_path_namespaceObject.dirname)((0,external_url_namespaceObject.fileURLToPath)(import.meta.url));

const subprocess = (0,external_node_child_process_namespaceObject.spawn)('node', [(0,external_node_path_namespaceObject.resolve)(start_and_log_dirname, '..', 'server', 'index.cjs')]);

console.log('Starting Server Process...');
const subprocess = (0,external_node_child_process_namespaceObject.spawn)('node', [(0,external_node_path_namespaceObject.resolve)(start_and_log_dirname, '..', 'server', 'index.cjs')], {stdio: 'pipe'});
subprocess.stdout.pipe((0,external_node_fs_namespaceObject.createWriteStream)(logFile('out')));
subprocess.stderr.pipe((0,external_node_fs_namespaceObject.createWriteStream)(logFile('err')));
2 changes: 2 additions & 0 deletions src/server.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const { createApp } = require('turborepo-remote-cache');

console.log('Creating Turbo Cache Server...');
const app = createApp({trustProxy: true});

console.log(`Starting listening for requests on ${process.env.HOST}:${process.env.PORT}...`);
app.listen({ host: process.env.HOST, port: process.env.PORT }, (err) => {
if (err) {
console.error(err);
Expand Down
9 changes: 6 additions & 3 deletions src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
[resolve(__dirname, '..', 'start_and_log')],
{
detached: true,
stdio: 'ignore',
stdio: 'pipe',
env: {
...process.env,
HOST: host,
Expand All @@ -48,8 +48,9 @@ async function main() {
},
);

subprocess.stdout?.on('data', (data) => debug(data.toString()));
subprocess.stderr?.on('data', (data) => debug(data.toString()));
const pid = subprocess.pid?.toString();
subprocess.unref();

try {
debug(`Waiting for port ${port} to be used...`);
Expand All @@ -63,8 +64,10 @@ async function main() {
exportVariable('TURBO_API', `http://${host}:${port}`);
exportVariable('TURBO_TOKEN', token);
exportVariable('TURBO_TEAM', teamId);

process.exit(0);
} catch (e) {
throw new Error(`Turbo server failed to start on port: ${port}`);
throw new Error(`Turbo server failed to start on port: ${port}\n${e}`);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/start_and_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { logFile } from './logs.js';

const __dirname = dirname(fileURLToPath(import.meta.url));

const subprocess = spawn('node', [resolve(__dirname, '..', 'server', 'index.cjs')]);

console.log('Starting Server Process...');
const subprocess = spawn('node', [resolve(__dirname, '..', 'server', 'index.cjs')], {stdio: 'pipe'});
subprocess.stdout.pipe(createWriteStream(logFile('out')));
subprocess.stderr.pipe(createWriteStream(logFile('err')));

0 comments on commit 84a75f9

Please sign in to comment.