Medusa a hands on VPS

Table of Contents

Medusa a hands on VPS

  • Storefront
  • Admin

Recipe for E-commerce

Installation: (Storefront)

Next.js Starter Storefront

  • Docs

  • The Medusa application is made up of a

    • Node.js server
    • admin dashboard.
  • The storefront is installed and hosted separately from the Medusa application.

  • You have the flexibility to choose the frontend tech stack that you and your team are proficient in, and implement unique design systems and user experience.

  • The Next.js Starter Storefront provides

    • rich commerce features and a
    • sleek design.
  • Developers and businesses can

    • use it as-is or
    • build on top of it to tailor it
  • for the business’s

    • unique use case,
    • design,
    • Customer experience.

🏰 The Quest to Summon Medusa in the Digital Kingdom

A Legendary Guide to Conquering E-commerce in the Realm of VPS


📜 Prologue: The Great Digital Prophecy

Welcome, brave developer, to the mystical Digital Kingdom that dwells within your mighty Debian VPS! You have been chosen for a legendary quest - to awaken the ancient serpent-haired goddess Medusa, the most powerful e-commerce deity known to mortals. But beware! This is no simple task. You must first prepare the sacred foundations of your digital realm…


⚔️ Chapter I: Preparing the Sacred Foundations

“Before one can summon gods, one must sanctify the land”

🛡️ Blessing Your Digital Fortress

Your VPS kingdom must first be purified and strengthened. Speak these ancient incantations:

# Update the Royal Scrolls (package lists)
sudo apt update && sudo apt upgrade -y

# Summon the Essential Guardian Spirits
sudo apt install -y curl wget git build-essential software-properties-common apt-transport-https ca-certificates gnupg lsb-release

🏗️ Summoning the Node.js Spirit Guardians

The great Medusa speaks only in the tongue of Node.js (version 16 or higher). We shall summon these mystical beings:

# Invoke the NodeSource Oracle
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

# Bind the Node.js spirits to your realm
sudo apt install -y nodejs

# Verify the spirits have answered your call
node --version
npm --version

🐉 Chapter II: Awakening the PostgreSQL Dragon

“In the depths of your kingdom dwells a mighty data dragon”

🔮 The Dragon’s Summoning Ritual

PostgreSQL, the ancient data dragon, must be awakened to guard Medusa’s treasures:

# Summon the PostgreSQL Dragon from its slumber
sudo apt install -y postgresql postgresql-contrib

# Start the dragon's eternal vigil
sudo systemctl start postgresql
sudo systemctl enable postgresql

# Verify the dragon stirs
sudo systemctl status postgresql

👑 Crowning Yourself as Dragon Master

Now you must become the master of this data dragon:

# Transform into the PostgreSQL sage
sudo -u postgres psql

# Within the dragon's lair, create your royal database
CREATE DATABASE medusa_kingdom;

# Forge a new royal user for Medusa
CREATE USER medusa_lord WITH ENCRYPTED PASSWORD 'your_super_secret_royal_password';

# Grant dominion over the kingdom database
GRANT ALL PRIVILEGES ON DATABASE medusa_kingdom TO medusa_lord;

# Grant the power to create new realms (databases)
ALTER USER medusa_lord CREATEDB;

# Exit the dragon's lair
\q

🗝️ Securing the Dragon’s Lair

Configure the dragon to accept connections from your kingdom:

# Edit the dragon's access scrolls
sudo nano /etc/postgresql/*/main/pg_hba.conf

Add this line to allow local connections:

local   all             medusa_lord                             md5

Then edit the main configuration:

sudo nano /etc/postgresql/*/main/postgresql.conf

Find and uncomment:

listen_addresses = 'localhost'

Restart the dragon to apply the new enchantments:

sudo systemctl restart postgresql

🌟 Chapter III: The Great Medusa Summoning

“With foundations blessed and dragon tamed, the goddess may now rise”

🎭 Installing the Medusa CLI Artifact

First, we must obtain the sacred CLI tool:

# Install the Medusa Command Crystal globally
npm install -g @medusajs/medusa-cli

# Verify the crystal's power
medusa --version

🏛️ Creating Medusa’s Temple

Now we shall construct a magnificent temple for our goddess:

# Create the sacred directory
mkdir ~/medusa-kingdom
cd ~/medusa-kingdom

# Invoke the temple creation ritual
npx create-medusa-app@latest my-medusa-store

# Enter the newly created temple
cd my-medusa-store
  • Once the installation is done,
    • the Medusa Admin dashboard will open in your default browser at http://localhost:9000/app,
    • the Next.js Starter storefront will be running at http://localhost:8000.

📿 Configuring the Sacred Connection

Edit the mystical configuration scroll:

nano medusa-config.js

Configure your database connection:

module.exports = {
  projectConfig: {
    database_url:
      "postgres://medusa_lord:your_super_secret_royal_password@localhost:5432/medusa_kingdom",
    database_type: "postgres",
    store_cors: "http://localhost:8000,http://localhost:7001",
    admin_cors: "http://localhost:7001,http://localhost:7000",
    // Add your VPS IP for external access
    // store_cors: "http://your-vps-ip:8000",
    // admin_cors: "http://your-vps-ip:7001",
  },
  plugins: [
    // ... other plugins
  ],
};

🌊 The Great Migration Ritual

Perform the sacred database migration:

# Run the ancient migration spells
npx medusa migrations run

# Seed the kingdom with initial treasures
npx medusa seed -f ./data/seed.json

👤 Creating the First Royal Administrator

Forge the first admin user who will serve Medusa:

# Create the supreme administrator
npx medusa user -e admin@your-kingdom.com -p supersecret123
npx medusa user -e admin@medusajs.com -p supersecret

🚀 Chapter IV: Awakening the Goddess

“The moment of truth - shall Medusa rise?”

⚡ Starting the Core Temple Services

# In your medusa temple directory
npm run start

The goddess should now be stirring at http://localhost:9000

🎨 Awakening the Admin Portal

Open a new terminal scroll and summon the admin interface:

# Navigate to your kingdom
cd ~/medusa-kingdom/my-medusa-store

# Install the admin palace
npm install @medusajs/admin

# Start the admin palace
npm run dev

The admin palace should materialize at http://localhost:7001

🛍️ Summoning the Storefront

For the customer-facing realm:

# In a new terminal, create the storefront
npx create-next-app@latest my-medusa-storefront -e https://github.com/medusajs/nextjs-starter-medusa

cd my-medusa-storefront

# Install the storefront magic
npm install

# Start the customer realm
npm run dev

The customer realm appears at http://localhost:8000


🌐 Chapter V: Opening the Kingdom Gates

“Making your realm accessible to the outside world”

🔥 Configuring the Mystical Firewall

# Allow the sacred ports through your fortress walls
sudo ufw allow 22      # SSH (keep this for your own access)
sudo ufw allow 9000    # Medusa API
sudo ufw allow 7001    # Admin Dashboard
sudo ufw allow 8000    # Storefront
sudo ufw enable

🎭 Using Process Guardians (PM2)

Install PM2 to keep your services running eternally:

# Install PM2 - the eternal guardian
npm install -g pm2

# In your medusa directory, create ecosystem file
nano ecosystem.config.js

Add this configuration:

module.exports = {
  apps: [
    {
      name: "medusa-server",
      script: "npm",
      args: "start",
      cwd: "/home/your-username/medusa-kingdom/my-medusa-store",
      env: {
        NODE_ENV: "production",
      },
    },
    {
      name: "medusa-admin",
      script: "npm",
      args: "run dev",
      cwd: "/home/your-username/medusa-kingdom/my-medusa-store",
    },
  ],
};

Start your eternal guardians:

# Deploy the guardians
pm2 start ecosystem.config.js

# Ensure they restart after server reboots
pm2 startup
pm2 save

🏆 Chapter VI: Victory and Beyond

“Your kingdom now stands mighty and proud”

🎉 Accessing Your New Realm

  • Medusa API: http://your-vps-ip:9000
  • Admin Dashboard: http://your-vps-ip:7001
  • Storefront: http://your-vps-ip:8000

🔍 Monitoring Your Kingdom

# Check the status of your services
pm2 status

# View the sacred logs
pm2 logs

# Monitor system resources
htop

🛡️ Securing Your Kingdom

Consider these additional protections:

# Install nginx as a reverse proxy guardian
sudo apt install nginx

# Set up SSL certificates with Let's Encrypt
sudo apt install certbot python3-certbot-nginx

🎭 Epilogue: The Legend Continues

Congratulations, noble developer! You have successfully summoned the mighty Medusa in your Digital Kingdom. The serpent-haired goddess of e-commerce now dwells within your VPS, ready to serve customers and manage your digital marketplace.

Your quest may be complete, but your journey as a digital kingdom ruler has just begun. May your stores prosper and your customers find joy in the realm you have created!

Remember: With great power comes great responsibility. Keep your kingdom updated, your dragon fed (database maintained), and your goddess happy (Medusa updated).


🆘 Emergency Spells (Troubleshooting)

If your kingdom faces troubles:

# Check if PostgreSQL dragon is sleeping
sudo systemctl status postgresql

# Restart the dragon if needed
sudo systemctl restart postgresql

# Check Medusa's health
curl http://localhost:9000/health

# View detailed logs
pm2 logs medusa-server

Long live your Digital Kingdom! 🏰✨


Forgot PostgresSQL

Ah, brave warrior! 🛡️ It seems the PostgreSQL Dragon has awakened but refuses to recognize your authority! Fear not - this is a common trial that many adventurers face. The dragon requires a different approach to acknowledge you as its master.

🐉 Alternative Dragon Taming Rituals

Method 1: The Peer Authentication Spell ⚡

Since you’re the root administrator of this digital realm, let’s use your natural authority:

# First, check if you can access the dragon directly as yourself
sudo su - postgres

If that works, you’ll see your terminal change to show postgres@your-server:~$. Then simply type:

psql

Method 2: The Direct Incantation 🔮

If the above works, skip the sudo -u postgres psql and use this simpler spell:

# Direct access to the dragon's lair
sudo -i -u postgres psql

Method 3: The Root Authority Override 👑

Sometimes the dragon only bows to absolute authority:

# Become the supreme ruler temporarily
sudo su
# Then transform into the postgres sage
su - postgres
# Finally enter the dragon's chamber
psql

Method 4: The Configuration Bypass 🗝️

If none of the above work, we’ll modify the dragon’s security settings temporarily:

# Edit the dragon's access scrolls
sudo nano /etc/postgresql/*/main/pg_hba.conf

Look for a line that says something like:

local   all             postgres                                peer

And temporarily change peer to trust, then save and exit.

Restart the dragon:

sudo systemctl restart postgresql

Now try:

sudo -u postgres psql

Important: Remember to change trust back to peer after you’ve set up your database and user!

🎭 Once You’re Inside the Dragon’s Lair

Whichever method gets you in, you’ll see something like:

postgres=#

This means you’ve successfully entered the dragon’s domain! Now perform the sacred database creation ritual:

-- Create the kingdom database
CREATE DATABASE medusa_kingdom;

-- Forge the royal user
CREATE USER medusa_lord WITH ENCRYPTED PASSWORD 'MedusaRoyalSecret2024!';

-- Grant dominion over the database
GRANT ALL PRIVILEGES ON DATABASE medusa_kingdom TO medusa_lord;

-- Grant database creation powers
ALTER USER medusa_lord CREATEDB;

-- Test your creation (optional)
\l  -- This lists all databases
\q  -- This exits the dragon's lair

🔍 Troubleshooting the Dragon’s Moods

If you’re still having trouble, let’s check the dragon’s status:

# Is the dragon even awake?
sudo systemctl status postgresql

# What version of dragon do we have?
sudo -u postgres psql -c "SELECT version();"

# Check if postgres user exists
cat /etc/passwd | grep postgres

Try one of these methods and let me know which one works for you! Once we’ve tamed this PostgreSQL dragon, we can continue with the epic Medusa summoning ritual! 🏰✨


Connection String:

Of course, noble database architect! 🏰⚡ Here are the sacred connection strings for your PostgreSQL dragon and medusa_lord:

🐉 The Sacred Connection Incantations

🔮 Standard PostgreSQL Connection String

postgres://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom

🎭 Alternative Format (some tools prefer this)

postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom

🏛️ Breaking Down the Mystical Components

postgresql://[username]:[password]@[host]:[port]/[database]
     ↓          ↓          ↓        ↓      ↓        ↓
postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom

Where:

  • Protocol: postgresql:// (the dragon’s language)
  • Username: medusa_lord (your royal database user)
  • Password: MedusaRoyalSecret2024! (replace with YOUR actual password)
  • Host: localhost (your VPS, locally)
  • Port: 5432 (PostgreSQL’s default portal)
  • Database: medusa_kingdom (your main realm)

⚔️ For Your Medusa Configuration

In your medusa-config.js file, use this:

module.exports = {
  projectConfig: {
    database_url:
      "postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom",
    database_type: "postgres",
    // ... rest of your config
  },
};

🔍 Testing Your Connection String

You can test if it works with this magical incantation:

# Test the connection directly
psql "postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom"

# Or using environment variable style
PGPASSWORD='MedusaRoyalSecret2024!' psql -h localhost -U medusa_lord -d medusa_kingdom

🛡️ Security Note for Production

For production realms, consider using environment variables instead of hardcoding passwords:

// In medusa-config.js
module.exports = {
  projectConfig: {
    database_url:
      process.env.DATABASE_URL ||
      "postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom",
    database_type: "postgres",
  },
};

Then set the environment variable:

export DATABASE_URL="postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_kingdom"

🎯 Alternative Connection Strings for Different Realms

If you create multiple kingdoms:

# Production
postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_production

# Staging
postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_staging

# Development
postgresql://medusa_lord:MedusaRoyalSecret2024!@localhost:5432/medusa_development

Remember: Replace MedusaRoyalSecret2024! with whatever password you actually used when creating the medusa_lord user!



Error:

Error: listen EADDRINUSE: address already in use :::9000
    at Server.setupListenHandle [as _listen2] (node:net:1939:16)
    at listenInCluster (node:net:1996:12)
    at Server.listen (node:net:2101:7)
    at internalStart (/home/atuld/the-protector/the-protector/node_modules/@medusajs/medusa/src/commands/start.ts:208:15)
    at async start (/home/atuld/the-protector/the-protector/node_modules/@medusajs/medusa/src/commands/start.ts:290:5) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 9000
}

After running:

npx create-medusa-app@latest --with-nextjs-starter
sudo netstat -tulnp

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp6       0      0 :::9000                 :::*                    LISTEN      12851/node

node seems to be running there.

i will have to update the medusa to use another port.


Ah ha! 🏰⚔️ The Digital Kingdom has a classic case of Port Siege Warfare!

Some rogue process has already claimed the sacred portal 9000 and refuses to yield! Fear not, brave developer - we have several battle strategies to reclaim your kingdom!

🗡️ Battle Strategy 1: Vanquish the Port Invader

First, let’s identify and eliminate this digital usurper:

# Identify the invading process
ps aux | grep 12851

# If it's another Medusa instance or unwanted process, banish it!
sudo kill -9 12851

# Verify the port is now free
sudo netstat -tulnp | grep 9000

🏰 Battle Strategy 2: Relocate Your Kingdom (Change Port)

If you prefer to establish your kingdom on a different sacred portal:

Method A: Environment Variable Magic 🔮

# Set a new royal port
export PORT=9001

# Then start your kingdom
npm run start

Method B: Medusa Configuration Scroll 📜

Edit your medusa-config.js:

module.exports = {
  projectConfig: {
    database_url:
      "postgresql://medusa_lord:your_password@localhost:5432/medusa_kingdom",
    database_type: "postgres",
    store_cors: "http://localhost:8000,http://localhost:7001",
    admin_cors: "http://localhost:7001,http://localhost:7000",
    // Add custom port configuration
    port: 9001, // or any available port you prefer
  },
  plugins: [
    // ... your plugins
  ],
};

Method C: Package.json Modification ⚔️

Edit your package.json scripts section:

{
  "scripts": {
    "start": "medusa start --port 9001",
    "dev": "medusa develop --port 9001"
  }
}

🕵️ Investigating the Mysterious Port Occupant

Let’s see what dares to occupy your royal portal:

# Get detailed info about the port occupant
sudo lsof -i :9000

# Or check what's running on that specific PID
ps -fp 12851

# Check if it's another Medusa instance
ps aux | grep medusa

🔄 Complete Kingdom Restart Ritual

If you want to completely restart your digital realm:

# Find and eliminate ALL Medusa processes
pkill -f medusa

# Find and eliminate ALL node processes (be careful with this!)
# pkill -f node  # Use with caution!

# Or more targeted approach
ps aux | grep node
# Then kill specific PIDs: sudo kill -9 [PID]

# Verify ports are free
sudo netstat -tulnp | grep -E ':(9000|7001|8000)'

# Now restart your kingdom
npm run start

I suggest using port 9001 for your Medusa kingdom since 9000 is occupied:

# Quick solution - start with different port
PORT=9001 npm run start

Your kingdom will then be accessible at:

  • Medusa API: http://your-vps-ip:9001
  • Admin Dashboard: http://your-vps-ip:7001 (if not also occupied)
  • Storefront: http://your-vps-ip:8000 (if not also occupied)

🛡️ Firewall Update for New Port

Don’t forget to update your fortress walls:

# Allow the new royal port
sudo ufw allow 9001

# You can remove the old port if not needed
# sudo ufw delete allow 9000

🛡️ The PM2 Guardian’s Complete Manual

Master the Art of Process Protection in Your Digital Kingdom


⚔️ Installing the Eternal Guardian

# Install PM2 globally - The Ultimate Process Guardian
npm install -g pm2

# Verify your guardian is ready
pm2 --version

🏰 Basic PM2 Battle Commands

Starting Your Digital Army

# Start a simple application
pm2 start app.js

# Start with custom name
pm2 start app.js --name "my-royal-app"

# Start npm script
pm2 start npm --name "medusa-api" -- start

# Start with environment variables
pm2 start app.js --name "my-app" --env production

Commanding Your Forces

# List all processes
pm2 list
# or
pm2 status

# Stop a process
pm2 stop app-name
pm2 stop 0  # by ID

# Restart a process
pm2 restart app-name
pm2 restart all

# Delete/Kill a process
pm2 delete app-name
pm2 kill  # kills PM2 daemon entirely

# Reload (zero-downtime restart)
pm2 reload app-name

📜 The Sacred Ecosystem Configuration

Create your battle formation file:

nano ecosystem.config.js

🏛️ Complete Medusa Kingdom Ecosystem

module.exports = {
  apps: [
    {
      name: "medusa-api",
      script: "npm",
      args: "start",
      cwd: "/home/atuld/your-medusa-directory",
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: "1G",
      env: {
        NODE_ENV: "development",
        PORT: 9001,
      },
      env_production: {
        NODE_ENV: "production",
        PORT: 9001,
      },
      log_file: "/home/atuld/logs/medusa-api-combined.log",
      out_file: "/home/atuld/logs/medusa-api-out.log",
      error_file: "/home/atuld/logs/medusa-api-error.log",
      log_date_format: "YYYY-MM-DD HH:mm Z",
    },
    {
      name: "medusa-storefront",
      script: "npm",
      args: "run dev",
      cwd: "/home/atuld/your-storefront-directory",
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: "1G",
      env: {
        NODE_ENV: "development",
        NEXT_PUBLIC_MEDUSA_BACKEND_URL: "http://localhost:9001",
        MEDUSA_BACKEND_URL: "http://localhost:9001",
      },
      env_production: {
        NODE_ENV: "production",
        NEXT_PUBLIC_MEDUSA_BACKEND_URL: "http://localhost:9001",
        MEDUSA_BACKEND_URL: "http://localhost:9001",
      },
      log_file: "/home/atuld/logs/medusa-storefront-combined.log",
      out_file: "/home/atuld/logs/medusa-storefront-out.log",
      error_file: "/home/atuld/logs/medusa-storefront-error.log",
      log_date_format: "YYYY-MM-DD HH:mm Z",
    },
    {
      name: "medusa-admin",
      script: "npm",
      args: "run dev",
      cwd: "/home/atuld/your-medusa-directory",
      instances: 1,
      autorestart: true,
      watch: false,
      env: {
        NODE_ENV: "development",
      },
      log_file: "/home/atuld/logs/medusa-admin-combined.log",
      out_file: "/home/atuld/logs/medusa-admin-out.log",
      error_file: "/home/atuld/logs/medusa-admin-error.log",
    },
  ],
};

🚀 Deploy Your Army

# Create logs directory
mkdir -p ~/logs

# Deploy all applications
pm2 start ecosystem.config.js

# Deploy with specific environment
pm2 start ecosystem.config.js --env production

# Deploy only specific app from ecosystem
pm2 start ecosystem.config.js --only medusa-api

🔍 Monitoring & Surveillance Commands

Real-time Battle Status

# Live monitoring dashboard
pm2 monit

# Show detailed process info
pm2 show medusa-api

# Process list with details
pm2 list

# Show logs in real-time
pm2 logs
pm2 logs medusa-api
pm2 logs --lines 100  # Show last 100 lines

# Flush all logs
pm2 flush

System Health Checks

# Memory usage
pm2 status

# Detailed system info
pm2 info medusa-api

# Show PM2 process info
pm2 describe medusa-api

🛡️ Auto-Startup & Persistence

Make Your Army Immortal

# Generate startup script (run once)
pm2 startup

# This will show you a command to run with sudo, example:
# sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u atuld --hp /home/atuld

# Save current process list
pm2 save

# Test resurrection (optional)
pm2 kill
pm2 resurrect

Updating Saved Processes

# After making changes, update the saved list
pm2 save

# Remove from startup
pm2 unstartup systemd

⚡ Advanced PM2 Warfare

Environment Management

# Start with specific environment
pm2 start ecosystem.config.js --env production

# Update environment variables without restart
pm2 restart medusa-api --update-env

Process Scaling

# Scale to multiple instances
pm2 scale medusa-api 3

# Or set specific number
pm2 start app.js -i 4  # 4 instances
pm2 start app.js -i max  # CPU cores count

Memory Management

# Restart if memory exceeds limit
pm2 start app.js --max-memory-restart 1024M

# Monitor memory usage
pm2 monit

📊 Logging Mastery

Log Commands

# View logs
pm2 logs
pm2 logs medusa-api
pm2 logs medusa-api --lines 50

# Empty all logs
pm2 flush

# Rotate logs
pm2 install pm2-logrotate

# Configure log rotation
pm2 set pm2-logrotate:max_size 10M
pm2 set pm2-logrotate:retain 7
pm2 set pm2-logrotate:compress true

Custom Log Paths

// In ecosystem.config.js
{
  name: 'my-app',
  script: 'app.js',
  out_file: './logs/out.log',
  error_file: './logs/error.log',
  log_file: './logs/combined.log',
  time: true
}

🔧 Troubleshooting Your Digital Army

Common Battle Commands

# Kill all PM2 processes
pm2 kill

# Restart PM2 daemon
pm2 kill && pm2 start ecosystem.config.js

# Check PM2 version
pm2 --version

# Update PM2
npm install -g pm2@latest
pm2 update

# Reset process counters
pm2 reset medusa-api

Health Checks

# Check if process is running
pm2 describe medusa-api

# Ping PM2 daemon
pm2 ping

# Show PM2 configuration
pm2 config

🎯 Your Medusa Kingdom Quick Commands

Essential Daily Commands

# Deploy your kingdom
pm2 start ecosystem.config.js

# Check kingdom status
pm2 status

# View kingdom logs
pm2 logs

# Restart troubled services
pm2 restart medusa-storefront

# Monitor real-time
pm2 monit

# Save your kingdom state
pm2 save

Emergency Commands

# Nuclear restart (if everything breaks)
pm2 kill
pm2 start ecosystem.config.js
pm2 save

# Check what's consuming resources
pm2 monit

# Restart specific service having issues
pm2 restart medusa-api

🏆 Victory Configuration Template

Save this as your ultimate ecosystem.config.js:

Your PM2 arsenal is now complete, noble VPS commander! 🏰⚔️

Quick Start Your Kingdom:

# 1. Create the logs directory
mkdir -p ~/logs

# 2. Update paths in ecosystem.config.js
# 3. Deploy your army
pm2 start ecosystem.config.js

# 4. Make it immortal
pm2 startup
pm2 save

# 5. Monitor your realm
pm2 monit
Tags :