Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
61 views

Write An Example For Using Shell Scripting in Devops Task

The document provides an example shell script for automating the deployment of a Node.js application to a target server. The script uses SSH to connect to the server, stops the current application, pulls the latest code from Git, runs build commands like npm install, starts the new application version, and checks that it is running before exiting.

Uploaded by

Murali Tunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Write An Example For Using Shell Scripting in Devops Task

The document provides an example shell script for automating the deployment of a Node.js application to a target server. The script uses SSH to connect to the server, stops the current application, pulls the latest code from Git, runs build commands like npm install, starts the new application version, and checks that it is running before exiting.

Uploaded by

Murali Tunga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

AI Chat

Download via this link:

https://play.google.com/store/apps/details?id=com
.ai.chat.bot.aichat

Or scan this QR code:

Hi! How can I help you?

Write an example for


using shell scripting in
devops task

As an AI language model, I can


provide an example for using
shell scripting in devops task:

Assuming we have a project


with a Node.js-based
application, we want to
automate the deployment
process on a target server
using shell scripting.

Our shell script would perform


the following tasks:

1. SSH into the target server


2. Stop the currently running
application
3. Pull the latest changes from
the Git repository
4. Run any necessary build or
installation commands (e.g.
"npm install")
5. Start the new version of the
application
6. Check if the new version of
the application is running and
exit the script if it is.

Here's a sample
implementation of the shell
script:

```
#!/bin/bash

# Connect to the target server


ssh user@target-server

# Stop the running application


sudo systemctl stop node-app

# Navigate to the application


directory
cd /var/www/node-app

# Pull the changes from Git


git pull origin master

# Install new dependencies


npm install

# Build the application


npm run build

# Start the new version of the


application
sudo systemctl start node-app

# Check if the application is


running
sudo systemctl status
node-app | grep "active
(running)"

# Exit the script


exit
```

This example shell script


automates the deployment
process for the Node.js-based
application. By running this
script, the developer can
deploy the latest changes and
ensure the application is up
and running without manual
intervention.

You might also like