Stabilize Cloud Run startup order
This commit is contained in:
parent
3c74c2e686
commit
c6117dcf4c
@ -72,14 +72,23 @@ ENV APP_SHELL_PORT=4000
|
|||||||
|
|
||||||
|
|
||||||
CMD ["sh", "-c", "\
|
CMD ["sh", "-c", "\
|
||||||
yarn --cwd /app/frontend dev & echo $! > /app/pids/frontend.pid && \
|
set -e; \
|
||||||
yarn --cwd /app/backend start & echo $! > /app/pids/backend.pid && \
|
echo 'Preparing repository before starting app processes...' ; \
|
||||||
sleep 10 && nginx -g 'daemon off;' & \
|
yarn --cwd /app/app-shell init-repo; \
|
||||||
NGINX_PID=$! && \
|
yarn --cwd /app/frontend dev & echo $! > /app/pids/frontend.pid; \
|
||||||
echo 'Waiting for backend (port 3000) to be available...' && \
|
yarn --cwd /app/backend start & echo $! > /app/pids/backend.pid; \
|
||||||
|
APP_SHELL_SKIP_REPO_INIT=true yarn --cwd /app/app-shell start & echo $! > /app/pids/app-shell.pid; \
|
||||||
|
echo 'Waiting for frontend (port 3001) to be available...' ; \
|
||||||
|
while ! nc -z localhost ${FRONT_PORT}; do \
|
||||||
|
sleep 2; \
|
||||||
|
done; \
|
||||||
|
echo 'Waiting for backend (port 3000) to be available...' ; \
|
||||||
while ! nc -z localhost ${BACKEND_PORT}; do \
|
while ! nc -z localhost ${BACKEND_PORT}; do \
|
||||||
sleep 2; \
|
sleep 2; \
|
||||||
done && \
|
done; \
|
||||||
echo 'Backend is up. Starting app_shell for Git check...' && \
|
echo 'Waiting for app_shell (port 4000) to be available...' ; \
|
||||||
yarn --cwd /app/app-shell start && \
|
while ! nc -z localhost ${APP_SHELL_PORT}; do \
|
||||||
wait $NGINX_PID"]
|
sleep 2; \
|
||||||
|
done; \
|
||||||
|
echo 'All app processes are up. Starting nginx...' ; \
|
||||||
|
exec nginx -g 'daemon off;'"]
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"name": "app-shell",
|
"name": "app-shell",
|
||||||
"description": "app-shell",
|
"description": "app-shell",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"init-repo": "node ./src/init-repo.js",
|
||||||
"start": "node ./src/index.js"
|
"start": "node ./src/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@ -32,8 +32,7 @@ function runGitCheck() {
|
|||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('Error during repo initialization:', err);
|
console.error('Error during repo initialization:', err);
|
||||||
// Optionally exit the process if Git check is critical:
|
process.exit(1);
|
||||||
// process.exit(1);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +47,8 @@ app.use('/vcs', vcsRoutes);
|
|||||||
// Start the app_shell server
|
// Start the app_shell server
|
||||||
startServer();
|
startServer();
|
||||||
|
|
||||||
// Now perform Git check
|
if (process.env.APP_SHELL_SKIP_REPO_INIT !== 'true') {
|
||||||
runGitCheck();
|
runGitCheck();
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
|||||||
16
app-shell/src/init-repo.js
Normal file
16
app-shell/src/init-repo.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
const VCS = require('./services/vcs');
|
||||||
|
|
||||||
|
const projectId = '32694';
|
||||||
|
|
||||||
|
VCS.initRepo(projectId)
|
||||||
|
.then((result) => {
|
||||||
|
if (result && result.message) {
|
||||||
|
console.log(result.message);
|
||||||
|
} else {
|
||||||
|
console.log(result);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error during repo initialization:', error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user