Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added Talawa-admin to run system daemon service in Linux, Added Eslint for Markdown file and updated the deprecated eslint #3130

Closed
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2c61c48
talawa_admin.service file added
sahitya-chandra Jan 3, 2025
325ec7d
.eslintignore deleted and INSTALLATION.md updated
sahitya-chandra Jan 3, 2025
b001089
INSTALLATION.md file updated
sahitya-chandra Jan 3, 2025
95a6a38
some refactor
sahitya-chandra Jan 3, 2025
84389ba
coderabbit refactor added
sahitya-chandra Jan 3, 2025
ead061c
docs refactor
sahitya-chandra Jan 3, 2025
1032f49
directory permission docs updated
sahitya-chandra Jan 3, 2025
e91881b
lint fix
sahitya-chandra Jan 5, 2025
50a113f
lint fix
sahitya-chandra Jan 5, 2025
2afb106
CODEROOT added
sahitya-chandra Jan 5, 2025
8519aad
CODEROOT suggestion added
sahitya-chandra Jan 5, 2025
e388e89
Daemon service setup markdown file added
sahitya-chandra Jan 5, 2025
c9d035d
changes reset
sahitya-chandra Jan 5, 2025
fc675f8
added eslint for markdown files
sahitya-chandra Jan 6, 2025
137d731
testing-library/react removed on coderabbit suggestion
sahitya-chandra Jan 6, 2025
079540d
Merge branch 'develop-postgres' into linux-systemd-service
sahitya-chandra Jan 9, 2025
bc11733
Updated .eslintrc.json
sahitya-chandra Jan 9, 2025
ae588d3
.eslintignore deleted and INSTALLATION.md updated
sahitya-chandra Jan 3, 2025
f4dc91c
some fixes
sahitya-chandra Jan 9, 2025
90b5ae2
refactor done
sahitya-chandra Jan 9, 2025
8432fba
merge conflict resolved
sahitya-chandra Jan 9, 2025
e544362
fixes
sahitya-chandra Jan 9, 2025
be02982
some code cleanup
sahitya-chandra Jan 14, 2025
3388e02
Merge branch 'develop-postgres' into linux-systemd-service
sahitya-chandra Jan 14, 2025
3c6506a
docs update
sahitya-chandra Jan 14, 2025
95697b8
docs update
sahitya-chandra Jan 14, 2025
117baa3
docs updated according to code rabbit
sahitya-chandra Jan 14, 2025
5399d22
docs updated according to code rabbit
sahitya-chandra Jan 14, 2025
8d30102
docs updated
sahitya-chandra Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

24 changes: 23 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in .eslintrc.json

View workflow job for this annotation

GitHub Actions / Performs linting, formatting, type-checking, checking for different source and target branch

File ignored by default.
"env": {
"browser": true,
"node": true,
Expand Down Expand Up @@ -33,8 +33,24 @@
"jest",
"import",
"eslint-plugin-tsdoc",
"prettier"
"prettier",
"markdown"
],

"overrides": [
{
"files": ["**/*.md"],
"processor": "markdown/markdown"
},
{
"files": ["**/*.md/*.js"],
"rules": {
"no-unused-vars": "off",
"no-undef": "off"
}
}
],
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved

"rules": {
"react/destructuring-assignment": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
Expand Down Expand Up @@ -149,6 +165,12 @@
"**/*.less",
"**/*.json",
"**/*.svg",
"src/components/CheckIn/tagTemplate.ts",
"package.json",
"package-lock.json",
"tsconfig.json",
"docs/**",
"examples/**",
"docs/docusaurus.config.ts",
"docs/sidebars.ts",
"docs/src/**",
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ The process of proposing a change to Talawa Admin can be summarized as:
```
npm install
npm run test --watchAll=false --coverage
genhtml coverage/lcov.info -o coverage
genhtml coverage/jest/lcov.info -o coverage
```
3. The output of the `npm run test` command will give you a tablular coverage report per file
4. The overall coverage rate will be visible on the penultimate line of the `genhtml` command's output.
Expand Down
91 changes: 91 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ This document provides instructions on how to set up and start a running instanc
- [Installation using Docker](#installation-using-docker)
- [Prerequisites](#prerequisites-1)
- [Development Setup](#development-setup)
- [Talawa-Admin Service Setup Guide](#talawa-admin-service-setup-guide)
- [Prerequisites](#prerequisites-2)
- [Service Configuration](#service-configuration)
- [1. **Copy the `talawa_admin.service` file**](#1-copy-the-talawa_adminservice-file)
- [2. **Verify the CODEROOT Path**](#2-verify-the-coderoot-path)
- [3. **Set the Correct Working Directory**](#3-set-the-correct-working-directory)
- [4. **Ensure the `.env` File Exists**](#4-ensure-the-env-file-exists)
- [5. **Adjust User and Group**](#5-adjust-user-and-group)
- [Steps to Enable and Manage the Service](#steps-to-enable-and-manage-the-service)
- [Troubleshooting](#troubleshooting)

<!-- tocstop -->

Expand Down Expand Up @@ -380,3 +390,84 @@ If you don't want this hook to run, you can manually opt out of this using the `

<br/>
```

# Talawa-Admin Service Setup Guide

This guide outlines the steps to set up and manage the Talawa-Admin service on a Linux server using `systemd`.

## Prerequisites

- Firstly, You should have locally setup the Talawa-Admin repo using [Setting up this repository](#setting-up-this-repository)
- Ensure **Node.js** and **npm** are correctly installed and available for the specified user and group.
- It’s recommended to use **nvm** (Node Version Manager) for better management of different Node.js versions.
- Ensure you have root or sudo access to configure systemd services.
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved
- Create a dedicated service user:
```bash
sudo useradd -r -s /bin/false talawa_admin
sudo groupadd -r talawa_admin
sudo usermod -a -G talawa_admin talawa_admin
# Set proper directory permissions
sudo chown -R talawa_admin:talawa_admin /path/to/talawa-admin
sudo chmod 750 /path/to/talawa-admin
sudo find /path/to/talawa-admin -type f -exec chmod 640 {} \
sudo chmod 600 /path/to/talawa-admin/.env
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved
```

---

### Service Configuration

#### 1. **Copy the `talawa_admin.service` file**
- Place the `talawa_admin.service` file in the appropriate systemd directory based on your Linux distribution:
- For most distributions: `/etc/systemd/system/`
- For systems using `systemd`, this will be the default directory.

sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved
#### 2. **Verify the CODEROOT Path**
- Ensure that the `CODEROOT` environment variable matches the absolute path to the Talawa-Admin code directory.

#### 3. **Set the Correct Working Directory**
- Always use the absolute path for the `WorkingDirectory`. Do **not** use `$CODEROOT` in the `WorkingDirectory` field.

#### 4. **Ensure the `.env` File Exists**
- Verify that the path in the `EnvironmentFile` line points to a valid `.env` file located in the root directory of the Talawa-Admin repository.

sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved
#### 5. **Adjust User and Group**
- Modify the `User` and `Group` settings to match the user account intended to run the service.

sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved
---

### Steps to Enable and Manage the Service

1. **Reload the systemd daemon** to apply changes:
```bash
sudo systemctl daemon-reload
```

2. **Start the Talawa-Admin Service**:
```bash
sudo systemctl start talawa_admin.service
```
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved

3. **Stop the Talawa-Admin Service**:
```bash
sudo systemctl stop talawa_admin.service
```

4. **Enable the Service to Start on Boot**:
```bash
sudo systemctl enable talawa_admin.service
```

---

### Troubleshooting

- If you encounter any issues, you can check the status and logs of the service:
```bash
sudo systemctl status talawa_admin.service
sudo journalctl -u talawa_admin.service
```

---

By following these steps, you can set up and manage the Talawa-Admin service efficiently on your Linux server.
65 changes: 65 additions & 0 deletions examples/linux/systemd/talawa_admin.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

################################################################################
#
# READ ALL STEPS BEFORE PROCEEDING
#
# 0) Ensure that Node.js and npm are correctly installed and available for the
# specified user and group.
# Use nvm for better interaction with different node versions.
# 1) Place this file in the appropriate systemd directory based on your Linux
# distribution, e.g., /etc/systemd/system/.
# 2) Verify the CODEROOT path matches the Talawa-Admin code directory.
# 3) Always add the absolute path of talawa-admin directory to WorkingDirectory don't use $CODEROOT.
# 4) Ensure the EnvironmentFile path points to a valid .env file for the service.
# 5) Adjust the User and Group to match the user account intended to run the service.
# 6) Run the command "sudo systemctl daemon-reload" after saving changes.
# 7) Use "sudo systemctl start talawa_admin.service" to start the service.
# 8) Use "sudo systemctl stop talawa_admin.service" to stop the service.
# 9) Use "sudo systemctl enable talawa_admin.service" to start the service on boot.
#
################################################################################
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved

[Unit]
Description=Talawa-Admin Service
After=network.target

[Service]
User=talawa_admin
Group=talawa_admin
Environment=CODEROOT=path/to/your/talawa-admin
Environment=NODE_ENV=production

# Absolute path is needed for working directory
WorkingDirectory=/path/to/your/talawa-admin
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved

################################################################################
# No need to edit anything below here
################################################################################

EnvironmentFile=$CODEROOT/.env
sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved
ExecStart=/bin/bash -c '\
if [ -f "$HOME/.nvm/nvm.sh" ]; then \
. "$HOME/.nvm/nvm.sh" && \
if nvm use default; then \
exec npm run serve \
else \
echo "Failed to set Node.js version" >&2; \
exit 1; \
fi \
else \
echo "NVM not found" >&2; \
exit 1; \
fi'

Restart=on-failure
RemainAfterExit=yes
ProtectSystem=full
NoNewPrivileges=true
PrivateTmp=true
Type=simple
RuntimeDirectory=talawa-admin

sahitya-chandra marked this conversation as resolved.
Show resolved Hide resolved

[Install]
WantedBy=multi-user.target

Loading
Loading