Managing and Deploying Your Service with HostingUp
Deploying a Bot on a VPS with Docker
Deploying a bot on a VPS (Virtual Private Server) using Docker can streamline the process and provide a consistent environment for your bot to run. Whether you're deploying a file stream bot, mirror bot, or leech bot, this guide will help you deploy your bot efficiently on a HostingUp VPS.
Method: Simple Commands for Quick Setup
For a streamlined setup based on your Dockerfile configuration, follow these steps. This method is ideal for new VPS users with the latest setup. Existing VPS users may need to reinstall the OS to use these commands.
If Your Procfile Uses python -m
To Start Your Bot (All Bots):
Use the following command:
hdocker <your-repo-url> <port number>
Example:
hdocker https://github.com/your-username/your-repo.git 9083
To Stop Your Bot:
Use the following command:
hclosed <Repo-Name>
Example: hclosed your-repo
Instructions:
- Replace
https://github.com/your-username/your-repo.git
with your repository URL. - Replace
<port number>
with the port number provided by HostingUp via email. - Replace
<Repo-Name>
with your repository folder name.
Benefits:
- Automatic Server Setup: Simplifies the initial configuration.
- Continuous 24/7 Operation: Ensures your bot runs without interruption.
- Automatic Restarts: Bot restarts automatically after server reboots.
Managing and Monitoring Your Service
Re-deploying Bot with Changes
If you need to re-deploy the bot with some changes, follow these steps:
- Commit Changes to GitHub: Ensure that you have committed your changes to your GitHub repository. Changes made directly on the VPS will not be reflected unless they are pushed to your GitHub account.
- Run the Deployment Command: On the VPS, use the script with the following command:
hdocker <GitHub Repo URL> <port number>
This command will pull the latest changes from your GitHub repository and redeploy the bot with those updates.
By following these steps, the changes will be reflected, and the bot will be restarted with the updated code.
Checking Service Status
Viewing Docker Logs for Your Bot
To view the logs for your Docker container, you can use the following commands:
- Check Logs for a Specific Container:
docker logs <container_id_or_name>
Example:
docker logs mybot_container
- Follow Logs in Real-Time:
docker logs -f <container_id_or_name>
Example:
docker logs -f mybot_container
- View Recent Logs with Limited Lines:
docker logs --tail <number_of_lines> <container_id_or_name>
Example:
docker logs --tail 100 mybot_container
- Combine Log Viewing and Real-Time Following:
docker logs --tail <number_of_lines> -f <container_id_or_name>
Example:
docker logs --tail 100 -f mybot_container
Managing the Service
- List All Running Containers:
docker ps
Example output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1b2c3d4e5f6 mybot_image "python bot.py" 2 hours ago Up 2 hours 0.0.0.0:8080->8080/tcp mybot_container
- List All Containers (Running and Stopped):
docker ps -a
Example output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1b2c3d4e5f6 mybot_image "python bot.py" 2 hours ago Up 2 hours 0.0.0.0:8080->8080/tcp mybot_container
b2c3d4e5f6g7 oldbot_image "python old_bot.py" 5 hours ago Exited (0) 3 hours ago oldbot_container
- Inspect Container Status:
docker inspect <container_id_or_name>
Example:
docker inspect mybot_container
This will provide detailed JSON output including the status, configuration, and more.
- Check the Health Status of a Container:
docker inspect --format='{{json .State.Health}}' <container_id_or_name>
Example:
docker inspect --format='{{json .State.Health}}' mybot_container
Need Help?
If you encounter any issues or need further assistance, please contact our support team:
- Email: [email protected]
- Phone: +91 01169652705
Explore our affiliate program to learn how you can benefit from HostingUp.
Watch Our Tutorial
For a visual guide, check out our YouTube tutorial: