mirror of
https://github.com/ghndrx/GSP662.git
synced 2026-02-10 15:04:57 +00:00
Complete restructure
This commit is contained in:
36
modules/storage/startup-script.sh
Normal file
36
modules/storage/startup-script.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# Install logging monitor. The monitor will automatically pick up logs sent to
|
||||
# syslog.
|
||||
curl -s "https://storage.googleapis.com/signals-agents/logging/google-fluentd-install.sh" | bash
|
||||
service google-fluentd restart &
|
||||
# Install dependencies from apt
|
||||
apt-get update
|
||||
apt-get install -yq ca-certificates git build-essential supervisor psmisc
|
||||
# Install nodejs
|
||||
mkdir /opt/nodejs
|
||||
curl https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.gz | tar xvzf - -C /opt/nodejs --strip-components=1
|
||||
ln -s /opt/nodejs/bin/node /usr/bin/node
|
||||
ln -s /opt/nodejs/bin/npm /usr/bin/npm
|
||||
# Get the application source code from the Google Cloud Storage bucket.
|
||||
mkdir /fancy-store
|
||||
gsutil -m cp -r gs://fancy-store-${var.project_id}/monolith-to-microservices/microservices/* /fancy-store/
|
||||
# Install app dependencies.
|
||||
cd /fancy-store/
|
||||
npm install
|
||||
# Create a nodeapp user. The application will run as this user.
|
||||
useradd -m -d /home/nodeapp nodeapp
|
||||
chown -R nodeapp:nodeapp /opt/app
|
||||
# Configure supervisor to run the node app.
|
||||
cat >/etc/supervisor/conf.d/node-app.conf << EOF
|
||||
[program:nodeapp]
|
||||
directory=/fancy-store
|
||||
command=npm start
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=nodeapp
|
||||
environment=HOME="/home/nodeapp",USER="nodeapp",NODE_ENV="production"
|
||||
stdout_logfile=syslog
|
||||
stderr_logfile=syslog
|
||||
EOF
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
Reference in New Issue
Block a user