Skip to content

Commit

Permalink
restart next server in start command
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfinnarn committed Mar 4, 2024
1 parent c4d1356 commit e429472
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 16 deletions.
8 changes: 7 additions & 1 deletion .tugboat/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
# General useful development tools
- apt-get install jq nano

# @todo Can cypress/included image be used instead?
# cypress-axe dependencies - https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements
- apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb

Expand Down Expand Up @@ -73,6 +74,7 @@ services:
# The internal tools ALB idle timeout is set to longer than a typical GQL query takes.
- sed -e 's/KeepAliveTimeout 5/KeepAliveTimeout 185/' -i /etc/apache2/apache2.conf

# @todo These should be aligned with other environments...
# BRD Environments are set to 1G, Tugboat and Lando are -1 (unlimited).
- echo "memory_limit = 4G" >> /usr/local/etc/php/conf.d/my-php.ini
# Set unlimited memory limit for PHP CLI to allow Composer to run.
Expand Down Expand Up @@ -141,6 +143,7 @@ services:
- ./scripts/install-nvm.sh

# Ensure that we're using version 2 of composer.
# @todo I'm guessing it is always version two now...
- composer self-update --2

# Install the Task task runner/build tool.
Expand All @@ -163,6 +166,7 @@ services:
update:
# Install/update packages managed by composer, including drush.
# Composer options are in composer.json, 'config' key.
# @todo Isn't this already done in the build step?
- composer install
- bash -lc 'nvm install'
- bash -lc 'npm install'
Expand Down Expand Up @@ -192,6 +196,7 @@ services:

# This j2 command is shared in both the build & clone stages. If modifying, change the other too.
- j2 "${TUGBOAT_ROOT}/.tugboat/.env.j2" -o "${TUGBOAT_ROOT}/.env"
# @todo If this is shared, why not abstract it to a script?
# This command is shared by the clone and build stages, make sure to update both stages.
- j2 "${TUGBOAT_ROOT}/.web/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.web/403-error-document.html"
- j2 "${TUGBOAT_ROOT}/.storybook/403-error-document.j2.html" -o "${TUGBOAT_ROOT}/.storybook/403-error-document.html"
Expand All @@ -209,7 +214,6 @@ services:
- mkdir -p "${TUGBOAT_ROOT}/next/public"
- ln -snf "${TUGBOAT_ROOT}/vets-website/build/localhost/generated" "${TUGBOAT_ROOT}/next/public/generated"


# https://www.drush.org/latest/deploycommand/ (updatedb, cache:rebuild, config:import, deploy:hook)
- bash -lc 'drush deploy'

Expand Down Expand Up @@ -256,6 +260,8 @@ services:

# Put necessary env variables in place for next's Drupal Preview before building server
# Need to construct this way instead of TUGBOAT_DEFAULT_SERVICE_URL in order to drop the trailing /
# @todo Can the config file use set env vars and these commands set them?
# @todo e.g. TUGBOAT_DEFAULT_SERVICE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}
- echo "NEXT_PUBLIC_DRUPAL_BASE_URL=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
- echo "NEXT_IMAGE_DOMAIN=https://cms-${TUGBOAT_SERVICE_TOKEN}.${TUGBOAT_SERVICE_CONFIG_DOMAIN}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
- echo "DRUPAL_CLIENT_ID=${DRUPAL_CLIENT_ID}" >> ${TUGBOAT_ROOT}/next/envs/.env.tugboat
Expand Down
9 changes: 9 additions & 0 deletions scripts/next-build-frontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ else
echo "==> Using default next-build version" >> ${logfile}
fi

# Stop the next server.

# Install 3rd party deps.
echo "==> Installing yarn dependencies" >> ${logfile}
composer va:next:install &>> ${logfile}
Expand All @@ -99,10 +101,17 @@ else
echo "==> Using default vets-website version" >> ${logfile}
fi

# Build vets-website again.
${reporoot}/scripts/vets-web-setup.sh

# Run the build.
echo "==> Starting build" >> ${logfile}
composer va:next:build &>> ${logfile}

# Start next server.
echo "==> Starting next server" >> ${logfile}
composer va:next:start &>> ${logfile}

# After this point, we are less concerned with errors; the build has completed.
set +e

Expand Down
2 changes: 1 addition & 1 deletion scripts/next-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ source ~/.bashrc

cd "${ROOT}/next"

APP_ENV=${APP_ENV} yarn build:preview
yarn build:preview
18 changes: 10 additions & 8 deletions scripts/next-install.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#!/usr/bin/env bash

ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}}
if [ -n "${IS_DDEV_PROJECT}" ]; then
APP_ENV="local"
elif [ -n "${TUGBOAT_ROOT}" ]; then
APP_ENV="tugboat"
else
APP_ENV="tugboat"
fi

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
source ~/.bashrc

# Installs the content-build dependencies.
cd ${ROOT}

if [ ! -d next ]; then
# Clone full so git information is available for content release form.
Expand All @@ -17,8 +26,6 @@ else
fi

cd next
#repo_root="$(git rev-parse --show-toplevel)"
#pushd "${repo_root}" > /dev/null

nvm install 18.17.0
nvm use 18.17.0
Expand All @@ -31,9 +38,4 @@ echo "Node $(node -v)"
echo "NPM $(npm -v)"
echo "Yarn $(yarn -v)"

#not sure how popd works
#pushd "./next"
yarn install
#popd

#popd > /dev/null
23 changes: 19 additions & 4 deletions scripts/next-start.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
#!/usr/bin/env bash

ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}}
if [ -n "${IS_DDEV_PROJECT}" ]; then
APP_ENV="local"
elif [ -n "${TUGBOAT_ROOT}" ]; then
APP_ENV="tugboat"
else
APP_ENV="tugboat"
fi

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
source ~/.bashrc

cd next
cd ${ROOT}/next

# Kill any current running server.
# We can look for "/scripts/yarn/start.js" since that is what "yarn start" runs.
NEXT_SERVER_PIDS=$(ps aux | grep '[.]/scripts/yarn/start.js' | awk '{print $2}')

# Start the dev server. Vets-website assets will be available to the preview server after content-build builds them.
# APP_ENV=tugboat yarn dev
# In case we have multiple processes, loop through them.
for pid in ${NEXT_SERVER_PIDS}; do
kill $pid
done

# Start the dev server. Vets-website assets need to be in place prior to this build.
APP_ENV=tugboat yarn start
yarn start
13 changes: 11 additions & 2 deletions scripts/vets-web-setup.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#!/usr/bin/env bash

ROOT=${TUGBOAT_ROOT:-${DDEV_APPROOT:-/var/www/html}}
if [ -n "${IS_DDEV_PROJECT}" ]; then
APP_ENV="local"
elif [ -n "${TUGBOAT_ROOT}" ]; then
APP_ENV="tugboat"
else
APP_ENV="tugboat"
fi

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
source ~/.bashrc

cd ${ROOT}

# Installs & builds vets-website dependencies for next-build preview.
#if [ ! -d docroot/vendor/va-gov/vets-website ]; then
if [ ! -d vets-website ]; then
# Clone full so git information is available for content release form.
# I don't think this should be necessary, but branch information was not
Expand All @@ -16,7 +26,6 @@ else
echo "Repo vets-website already cloned."
fi

#cd docroot/vendor/va-gov/vets-website
cd vets-website

nvm install 14.15.1
Expand Down

0 comments on commit e429472

Please sign in to comment.