<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: CloudRay Staff</title>
    <description>The latest articles on Forem by CloudRay Staff (@cloudray-staff).</description>
    <link>https://forem.com/cloudray-staff</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2754626%2Fedd70656-c9c4-4eba-a7e4-f5ad06bd35d7.png</url>
      <title>Forem: CloudRay Staff</title>
      <link>https://forem.com/cloudray-staff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cloudray-staff"/>
    <language>en</language>
    <item>
      <title>Deploy Express.js &amp; Node Using Bash Scripts &amp; CloudRay</title>
      <dc:creator>CloudRay Staff</dc:creator>
      <pubDate>Sat, 04 Jan 2025 00:00:00 +0000</pubDate>
      <link>https://forem.com/cloudray-staff/deploy-expressjs-node-using-bash-scripts-cloudray-pnh</link>
      <guid>https://forem.com/cloudray-staff/deploy-expressjs-node-using-bash-scripts-cloudray-pnh</guid>
      <description>&lt;p&gt;In this guide, we’ll show you how to deploy your Express.js application using Bash scripts and &lt;a href="https://cloudray.io" rel="noopener noreferrer"&gt;CloudRay&lt;/a&gt;, a platform that simplifies server management and script execution. This approach is ideal for developers who are comfortable with Bash scripting and want a lightweight, efficient solution for deploying small to medium projects, without the overhead of Docker containerization or CI/CD pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Prerequisites&lt;/li&gt;
&lt;li&gt;Assumptions&lt;/li&gt;
&lt;li&gt;Adding Your Server to CloudRay&lt;/li&gt;
&lt;li&gt;Create the setup script&lt;/li&gt;
&lt;li&gt;Create the Deployment Script&lt;/li&gt;
&lt;li&gt;Create a Variable Group&lt;/li&gt;
&lt;li&gt;Run the setup script&lt;/li&gt;
&lt;li&gt;Run the deployment script&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A CloudRay account&lt;/strong&gt; at &lt;a href="https://app.cloudray.io/" rel="noopener noreferrer"&gt;app.cloudray.io&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An Express.js Application:&lt;/strong&gt; that is ready to deploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A cloud server accessible via SSH:&lt;/strong&gt; If you don’t already have a cloud server, you can get one from popular providers like &lt;a href="https://aws.amazon.com/" rel="noopener noreferrer"&gt;AWS&lt;/a&gt;, &lt;a href="https://www.digitalocean.com/" rel="noopener noreferrer"&gt;DigitalOcean&lt;/a&gt;, and &lt;a href="https://cloud.google.com/" rel="noopener noreferrer"&gt;Google Cloud&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSH credentials:&lt;/strong&gt; Ensure you have access to the necessary SSH keys or login credentials to access your server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Access Token:&lt;/strong&gt; You’ll need a fine-grained personal access token to clone your repository. Follow this &lt;a href="https://cloudray.io/articles/create-github-access-token" rel="noopener noreferrer"&gt;GitHub Access Token guide&lt;/a&gt; to create one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide assumes you’re using &lt;strong&gt;Ubuntu 24.04 LTS&lt;/strong&gt; as your server’s operating system. If you’re using a different version or a different distribution, adjust the commands accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Your Server to CloudRay
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdbtpe6cj5r9f3p5mtyw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdbtpe6cj5r9f3p5mtyw.png" alt="Screenshot of adding a new server" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you’ve already added your server to CloudRay, you can skip this step.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To deploy your application, you need to add your server to CloudRay so it can execute deployment scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps to add your server:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in to your CloudRay account.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;strong&gt;Servers&lt;/strong&gt; in the dashboard.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New Server&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Follow the on-screen instructions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For detailed guidance, refer to the &lt;a href="https://cloudray.io/docs/servers" rel="noopener noreferrer"&gt;Adding a Server documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once your server is added, proceed to the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the setup script
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpn1630qeiulbw79pthv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpn1630qeiulbw79pthv.png" alt="Screenshot of adding a new setup script" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To streamline the deployment process, you’ll need two Bash scripts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setup Script&lt;/strong&gt; : You’ll run this once when setting up a new server to install dependencies and configure services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment Script&lt;/strong&gt; : You can run this anytime you want to update your application with new code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this section, we’ll create the &lt;strong&gt;Setup Script&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The setup script prepares your server by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating a deploy user that runs the Node server using pm2 as a non-privileged service&lt;/li&gt;
&lt;li&gt;Installing Caddy web server for automatic HTTPS&lt;/li&gt;
&lt;li&gt;Setting up asdf to install Node.js&lt;/li&gt;
&lt;li&gt;Creating a systemd service to start pm2 at boot&lt;/li&gt;
&lt;li&gt;Setting up the repository for the first time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To create the setup script:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Scripts&lt;/strong&gt; in your CloudRay project&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;New Script&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Name: &lt;code&gt;Setup Express Server&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Copy this code:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Stop executing the script if any of the commands fail&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;

&lt;span class="c"&gt;# Create a deploy user if it doesn't exist&lt;/span&gt;
&lt;span class="c"&gt;# This is the user that will run the Express app&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[!&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; /home/deploy]&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Creating deploy user"&lt;/span&gt;
  adduser &lt;span class="nt"&gt;--disabled-password&lt;/span&gt; &lt;span class="nt"&gt;--gecos&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; deploy
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# We'll deploy the Express app to /srv&lt;/span&gt;
&lt;span class="c"&gt;# Let's ensure the deploy user has the right permissions&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Setting up /srv directory"&lt;/span&gt;
&lt;span class="nb"&gt;chown &lt;/span&gt;deploy:deploy &lt;span class="nt"&gt;-R&lt;/span&gt; /srv

&lt;span class="c"&gt;# Install the essential packages&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installing essential packages"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DEBIAN_FRONTEND&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;noninteractive
apt-get update
apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; git caddy

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Configuring Caddy to serve the Express app"&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/caddy/Caddyfile &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOT&lt;/span&gt;&lt;span class="sh"&gt;'
{{app_domain}} {
  reverse_proxy localhost:{{express_port}}
}
&lt;/span&gt;&lt;span class="no"&gt;EOT

&lt;/span&gt;&lt;span class="c"&gt;# We'll install asdf to manage node version&lt;/span&gt;
su &lt;span class="nt"&gt;-l&lt;/span&gt; deploy &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOT&lt;/span&gt;&lt;span class="sh"&gt;'
  set -e
  if [! -d "&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/.asdf"]; then
    echo "Installing asdf"
    git clone https://github.com/asdf-vm/asdf.git ~/.asdf
    echo "source &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/.asdf/asdf.sh" &amp;gt;&amp;gt; ~/.bashrc
  else
    echo "Updating asdf"
    cd ~/.asdf
    git pull
  fi

  source &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/.asdf/asdf.sh

  if ! grep -q "legacy_version_file" ~/.asdfrc; then
    echo "legacy_version_file = yes" &amp;gt;&amp;gt; ~/.asdfrc
  fi
  asdf plugin add nodejs
  echo "Installing Node.js version {{node_version}}"
  asdf install nodejs {{node_version}}
  asdf reshim
  asdf global nodejs {{node_version}}
  npm install -g pm2
  echo "Finished installing Node.js"
&lt;/span&gt;&lt;span class="no"&gt;EOT

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Creating the pm2 startup service"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ASDF_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/deploy/.asdf
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ASDF_DATA_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/home/deploy/.asdf
&lt;span class="nb"&gt;source&lt;/span&gt; /home/deploy/.asdf/asdf.sh
asdf shell nodejs &lt;span class="o"&gt;{{&lt;/span&gt;node_version&lt;span class="o"&gt;}}&lt;/span&gt;
pm2 startup systemd &lt;span class="nt"&gt;-u&lt;/span&gt; deploy &lt;span class="nt"&gt;--hp&lt;/span&gt; /home/deploy

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Setting up the repository for the first time"&lt;/span&gt;
su &lt;span class="nt"&gt;-l&lt;/span&gt; deploy &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOT&lt;/span&gt;&lt;span class="sh"&gt;'
  set -e
  source "&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/.asdf/asdf.sh"
  mkdir -p /srv/{{app_name}}
  cd /srv/{{app_name}}
  if [! -d "/srv/{{app_name}}/.git"]; then
    git clone https://{{github_access_token}}@github.com/{{github_repo_name}} .
  fi
  npm install
  pm2 stop {{app_name}} || true
  env PATH="&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;asdf where nodejs&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;/bin:&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="sh"&gt;" pm2 start npm --name {{app_name}} -- start
  pm2 save
&lt;/span&gt;&lt;span class="no"&gt;EOT

&lt;/span&gt;systemctl restart caddy.service

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Done."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;TIP&lt;/p&gt;

&lt;p&gt;If you find this script too long to manage, you can break it into smaller scripts and use &lt;a href="https://cloudray.io/docs/script-playlists" rel="noopener noreferrer"&gt;Script Playlists&lt;/a&gt; to run them together.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Create the Deployment Script
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkouoidral62enptiza0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvkouoidral62enptiza0.png" alt="Screenshot of adding a new deploy script" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll use this script whenever you want to update your application. The script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pulls latest code from your Git repository’s main branch&lt;/li&gt;
&lt;li&gt;Installs app dependencies&lt;/li&gt;
&lt;li&gt;Restarts the Node server using pm2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To create the deployment script:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Scripts&lt;/strong&gt; &amp;gt; &lt;strong&gt;New Script&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Name: &lt;code&gt;Deploy Express App&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add code:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;

su &lt;span class="nt"&gt;-l&lt;/span&gt; deploy &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOT&lt;/span&gt;&lt;span class="sh"&gt;'
set -e
. "&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="sh"&gt;/.asdf/asdf.sh"
cd /srv/{{app_name}}
git fetch --all
git reset --hard origin/main
npm install
pm2 restart {{app_name}}
&lt;/span&gt;&lt;span class="no"&gt;EOT

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"🚀 Deployed {{app_name}} at https://{{app_domain}}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create a Variable Group
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9mupkfkufp1sstjbcyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9mupkfkufp1sstjbcyj.png" alt="Screenshot of adding a new variable group" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our scripts use variables like &lt;code&gt;{{app_name}}&lt;/code&gt;, &lt;code&gt;{{app_domain}}&lt;/code&gt;, and &lt;code&gt;{{node_version}}&lt;/code&gt; because CloudRay processes all scripts as &lt;a href="https://shopify.github.io/liquid/" rel="noopener noreferrer"&gt;Liquid templates&lt;/a&gt;. This allows you to use placeholders in your scripts, making them dynamic and reusable across different servers.&lt;/p&gt;

&lt;p&gt;To provide values for these variables, you’ll need to create a variable group. Here’s how:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Navigate to Variable Groups:&lt;/strong&gt; In your CloudRay project, go to “Scripts” in the top menu and click on “Variable Groups”.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create a new Variable Group:&lt;/strong&gt; Click on “New Variable Group”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add the following variables:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;app_name&lt;/code&gt;:&lt;/strong&gt; Your application’s name (use underscores instead of spaces), e.g., &lt;code&gt;my_app&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;app_domain&lt;/code&gt;:&lt;/strong&gt; Your application’s domain name, e.g., &lt;code&gt;myapp.example.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;node_version&lt;/code&gt;:&lt;/strong&gt; The version of Node.js you want to install. E.g., &lt;code&gt;20.0.0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;express_port&lt;/code&gt;:&lt;/strong&gt; The port your Express application listens on (e.g., &lt;code&gt;3000&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;github_access_token&lt;/code&gt;:&lt;/strong&gt; Your GitHub personal access token for cloning the repository.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;github_repo_name&lt;/code&gt;:&lt;/strong&gt; Your GitHub repository in the format &lt;code&gt;username/repository&lt;/code&gt;, e.g., &lt;code&gt;yourusername/your-repo&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Run the setup script
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6vpp8s9y6alvyi34dird.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6vpp8s9y6alvyi34dird.png" alt="Screenshot of creating a new runlog" width="800" height="500"&gt;&lt;/a&gt; &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0brgnrera7x4whpyx702.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0brgnrera7x4whpyx702.png" alt="Screenshot of setup runlog" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run the &lt;code&gt;Setup Express Server&lt;/code&gt; script, you’ll use a Runlog in CloudRay. A Runlog allows you to execute scripts on your servers and provides detailed logs of the execution process.&lt;/p&gt;

&lt;p&gt;Here’s how to create and run a Runlog:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Navigate to Runlogs:&lt;/strong&gt; In your CloudRay project, go to “Runlogs” in the top menu.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create a new Runlog:&lt;/strong&gt; Click on “New Runlog”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fill in the form:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server:&lt;/strong&gt; Select the server you added earlier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Script:&lt;/strong&gt; Choose the &lt;code&gt;Setup Express Server&lt;/code&gt; script.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable Group:&lt;/strong&gt; Select the variable group you created earlier.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Run the script:&lt;/strong&gt; Click on “Run” to execute the script on your server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CloudRay will connect to your server, run the &lt;code&gt;Setup Express Server&lt;/code&gt; script, and show you the live output as the script executes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run the deployment script
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frifyb4xnwrjda7lomz7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frifyb4xnwrjda7lomz7h.png" alt="Screenshot of deploy runlog" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can run the &lt;code&gt;deploy-rails-app&lt;/code&gt; script whenever you want to deploy a new version of your application. Here’s how to create a Runlog for the deployment script:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Navigate to Runlogs:&lt;/strong&gt; In your CloudRay project, go to “Runlogs” in the top menu.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create a new Runlog:&lt;/strong&gt; Click on “New Runlog”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fill in the form:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server:&lt;/strong&gt; Select the server you added earlier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Script:&lt;/strong&gt; Choose the &lt;code&gt;Deploy Express App&lt;/code&gt; script.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Variable Group:&lt;/strong&gt; Select the variable group you created earlier.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Run the script:&lt;/strong&gt; Click on “Run” to execute the script on your server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CloudRay will connect to your server, run the &lt;code&gt;Deploy Express App&lt;/code&gt; script, and show you the live output as the script executes.&lt;/p&gt;

&lt;p&gt;That’s it! Happy deploying!&lt;/p&gt;

&lt;p&gt;If you've any questions, let us know in the comments!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cloudray.io/" rel="noopener noreferrer"&gt;Get Started with CloudRay&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>node</category>
      <category>express</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
