38 lines
1.1 KiB
Bash
Executable File
38 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Create logs directory if it doesn't exist
|
|
mkdir -p logs
|
|
|
|
# Make sure the run_app.sh script is executable
|
|
chmod +x run_app.sh
|
|
|
|
# Check if PM2 is installed
|
|
if ! command -v pm2 &> /dev/null; then
|
|
echo "PM2 is not installed. Installing..."
|
|
npm install -g pm2
|
|
fi
|
|
|
|
# Start the application with PM2
|
|
echo "Starting Zulip Bot service with PM2..."
|
|
pm2 start ecosystem.config.js
|
|
|
|
# Save the current PM2 configuration
|
|
echo "Saving PM2 configuration..."
|
|
pm2 save
|
|
|
|
# Configure PM2 to start on boot (may require sudo)
|
|
echo "Setting up PM2 to start on system boot..."
|
|
if sudo pm2 startup | grep -q "sudo"; then
|
|
# If the output contains sudo commands, extract and run them
|
|
sudo_cmd=$(sudo pm2 startup | grep "sudo" | tail -n 1)
|
|
echo "Run the following command with sudo privileges to enable PM2 on startup:"
|
|
echo "$sudo_cmd"
|
|
else
|
|
echo "PM2 startup configuration completed."
|
|
fi
|
|
|
|
echo "PM2 service setup complete. Zulip Bot is now running as a service."
|
|
echo "To check status: pm2 status"
|
|
echo "To view logs: pm2 logs zulip-bot"
|
|
echo "To restart: pm2 restart zulip-bot"
|
|
echo "To stop: pm2 stop zulip-bot" |