#!/bin/bash

# PM2 startup script for Contract Generator web app

# Navigate to the script's directory
cd "$(dirname "$0")"

# Create logs directory if it doesn't exist
mkdir -p logs

# Start the application with PM2
pm2 start ecosystem.config.js

# Display status
pm2 status

echo ""
echo "Contract Generator is now running with PM2!"
echo ""
echo "Useful PM2 commands:"
echo "  pm2 status              - View application status"
echo "  pm2 logs contract-generator  - View logs"
echo "  pm2 restart contract-generator - Restart the app"
echo "  pm2 stop contract-generator    - Stop the app"
echo "  pm2 delete contract-generator  - Remove from PM2"
echo "  pm2 save               - Save current PM2 process list"
echo "  pm2 startup            - Generate startup script"

