<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mr Vi</title>
    <description>The latest articles on DEV Community by Mr Vi (@mrvi0).</description>
    <link>https://dev.to/mrvi0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F987178%2Fa22d0025-6e48-4de3-b341-119e9ebf62b4.jpeg</url>
      <title>DEV Community: Mr Vi</title>
      <link>https://dev.to/mrvi0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrvi0"/>
    <language>en</language>
    <item>
      <title>Secure SSH Monitoring with Real-time Telegram Alerts</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Thu, 02 Oct 2025 06:39:18 +0000</pubDate>
      <link>https://dev.to/mrvi0/secure-ssh-monitoring-with-real-time-telegram-alerts-1oje</link>
      <guid>https://dev.to/mrvi0/secure-ssh-monitoring-with-real-time-telegram-alerts-1oje</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;A comprehensive guide to setting up automated SSH connection monitoring with Telegram notifications for enhanced server security.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  🚨 The Problem
&lt;/h2&gt;

&lt;p&gt;As a system administrator, you need to know &lt;strong&gt;immediately&lt;/strong&gt; when someone connects to your server via SSH. Whether it's a legitimate user or a potential security threat, real-time awareness is crucial for maintaining server security.&lt;/p&gt;

&lt;p&gt;Traditional approaches like checking logs manually or using basic monitoring tools often fall short because they:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Don't provide real-time alerts&lt;/li&gt;
&lt;li&gt;❌ Lack user identification details&lt;/li&gt;
&lt;li&gt;❌ Miss parallel connection attempts&lt;/li&gt;
&lt;li&gt;❌ Don't distinguish between different connection types&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💡 The Solution: SSH Alert
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SSH Alert&lt;/strong&gt; is a robust, open-source solution that provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔐 &lt;strong&gt;Maximum user identification&lt;/strong&gt; - IP address, key fingerprint, user comments&lt;/li&gt;
&lt;li&gt;📱 &lt;strong&gt;Real-time Telegram notifications&lt;/strong&gt; - Instant alerts with detailed information&lt;/li&gt;
&lt;li&gt;🛡️ &lt;strong&gt;Smart rate limiting&lt;/strong&gt; - Prevents notification spam during parallel sessions&lt;/li&gt;
&lt;li&gt;⚙️ &lt;strong&gt;Flexible configuration&lt;/strong&gt; - Separate settings for different connection types&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Automatic retry logic&lt;/strong&gt; - Handles network failures gracefully&lt;/li&gt;
&lt;li&gt;📊 &lt;strong&gt;Comprehensive logging&lt;/strong&gt; - Detailed logs with optional JSON format&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 Quick Start
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Clone and install&lt;/span&gt;
git clone https://github.com/B4DCATs/ssh-login-alert
&lt;span class="nb"&gt;cd &lt;/span&gt;ssh-login-alert
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./install.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic Configuration
&lt;/h3&gt;

&lt;p&gt;Edit &lt;code&gt;/etc/ssh-alert/config.conf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Telegram Configuration&lt;/span&gt;
&lt;span class="nv"&gt;TELEGRAM_BOT_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your_bot_token_here"&lt;/span&gt;
&lt;span class="nv"&gt;TELEGRAM_CHAT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your_chat_id_here"&lt;/span&gt;

&lt;span class="c"&gt;# Server Information&lt;/span&gt;
&lt;span class="nv"&gt;SERVER_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"production-server"&lt;/span&gt;
&lt;span class="nv"&gt;SERVER_DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"example.com"&lt;/span&gt;

&lt;span class="c"&gt;# Notification Settings&lt;/span&gt;
&lt;span class="nv"&gt;NOTIFY_INTERACTIVE_SESSIONS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true
&lt;/span&gt;&lt;span class="nv"&gt;NOTIFY_TUNNELS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false
&lt;/span&gt;&lt;span class="nv"&gt;DISABLE_NOTIFICATION_SOUND_FOR_TUNNELS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;

&lt;span class="c"&gt;# Rate Limiting (seconds)&lt;/span&gt;
&lt;span class="nv"&gt;RATE_LIMIT_PER_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;300
&lt;span class="nv"&gt;RATE_LIMIT_PER_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;60
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔧 Advanced Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Enhanced User Identification
&lt;/h3&gt;

&lt;p&gt;Configure &lt;code&gt;authorized_keys&lt;/code&gt; for maximum user identification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add user identification to SSH keys&lt;/span&gt;
&lt;span class="nv"&gt;environment&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"SSH_USER=alice@company.com"&lt;/span&gt; ssh-rsa AAAAB3NzaC1yc2E... alice@laptop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. CI/CD Pipeline Exclusions
&lt;/h3&gt;

&lt;p&gt;Exclude automated connections from notifications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add exclusions for automated systems&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./manage-exclusions.sh add &lt;span class="s2"&gt;"pipeline@ci"&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./manage-exclusions.sh add &lt;span class="s2"&gt;"deploy@automation"&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./manage-exclusions.sh add &lt;span class="s2"&gt;"monitoring@system"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Smart Notification Types
&lt;/h3&gt;

&lt;p&gt;SSH Alert distinguishes between connection types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Interactive Shell&lt;/strong&gt; - Full terminal access (with sound notification)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSH Tunnel&lt;/strong&gt; - Port forwarding (silent notification)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command Execution&lt;/strong&gt; - Remote command execution (configurable)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Comprehensive Logging
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# View real-time logs&lt;/span&gt;
&lt;span class="nb"&gt;sudo tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /var/log/ssh-alert.log

&lt;span class="c"&gt;# Enable JSON logging for monitoring systems&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'JSON_LOGGING=true'&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/ssh-alert/config.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📱 Setting Up Telegram Bot
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Create Bot
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Message &lt;a href="https://t.me/BotFather" rel="noopener noreferrer"&gt;@BotFather&lt;/a&gt; on Telegram&lt;/li&gt;
&lt;li&gt;Send &lt;code&gt;/newbot&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Follow the instructions to create your bot&lt;/li&gt;
&lt;li&gt;Save the bot token&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Get Chat ID
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Add your bot to a chat or send it a message&lt;/li&gt;
&lt;li&gt;Visit: &lt;code&gt;https://api.telegram.org/bot&amp;lt;YOUR_BOT_TOKEN&amp;gt;/getUpdates&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Find your &lt;code&gt;chat.id&lt;/code&gt; in the response&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🛡️ Security Best Practices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Secure Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Restrict access to configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;600 /etc/ssh-alert/config.conf
&lt;span class="nb"&gt;sudo chown &lt;/span&gt;root:root /etc/ssh-alert/config.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Firewall Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Allow SSH only from trusted networks&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow from 192.168.1.0/24 to any port 22
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw deny 22
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. SSH Hardening
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Disable password authentication&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/ssh/sshd_config
&lt;span class="c"&gt;# Set: PasswordAuthentication no&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📊 Monitoring and Maintenance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  System Health Checks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check system status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status ssh-alert 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Service not installed"&lt;/span&gt;

&lt;span class="c"&gt;# View active connections&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;sshd

&lt;span class="c"&gt;# Check recent notifications&lt;/span&gt;
&lt;span class="nb"&gt;sudo grep&lt;/span&gt; &lt;span class="s2"&gt;"SSH alert sent"&lt;/span&gt; /var/log/ssh-alert.log | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Log Rotation
&lt;/h3&gt;

&lt;p&gt;SSH Alert automatically configures log rotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check rotation status&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./check-log-rotation.sh status

&lt;span class="c"&gt;# Test rotation configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./check-log-rotation.sh &lt;span class="nb"&gt;test&lt;/span&gt;

&lt;span class="c"&gt;# Force rotation&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./check-log-rotation.sh rotate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔍 Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Common Issues
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Notifications not arriving:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"TELEGRAM_BOT_TOKEN|TELEGRAM_CHAT_ID"&lt;/span&gt; /etc/ssh-alert/config.conf

&lt;span class="c"&gt;# Check logs&lt;/span&gt;
&lt;span class="nb"&gt;sudo tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /var/log/ssh-alert.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Script not starting:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check permissions&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /opt/ssh-alert/ssh-alert-enhanced.sh

&lt;span class="c"&gt;# Check syntax&lt;/span&gt;
bash &lt;span class="nt"&gt;-n&lt;/span&gt; /opt/ssh-alert/ssh-alert-enhanced.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Python errors:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check Python version&lt;/span&gt;
python3 &lt;span class="nt"&gt;--version&lt;/span&gt;

&lt;span class="c"&gt;# Test parser&lt;/span&gt;
python3 /opt/ssh-alert/key-parser.py get-info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📈 Example Notification
&lt;/h2&gt;

&lt;p&gt;Here's what you'll receive in Telegram:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🔐 SSH Login Alert:
Host IP: 203.0.113.1 / 192.168.1.100
Host: production-server.example.com
Person: alice@company.com
IP: 198.51.100.50
Type: Interactive shell
Key: SHA256:abcd1234...
Time: 2024-01-15 14:30:25 UTC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🎯 Use Cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Production Server Monitoring
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Real-time alerts for all SSH connections&lt;/li&gt;
&lt;li&gt;Distinguish between legitimate users and potential threats&lt;/li&gt;
&lt;li&gt;Track connection patterns and anomalies&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Development Environment
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Monitor team access to shared development servers&lt;/li&gt;
&lt;li&gt;Track deployment activities&lt;/li&gt;
&lt;li&gt;Ensure compliance with access policies&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Security Incident Response
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Immediate notification of unauthorized access attempts&lt;/li&gt;
&lt;li&gt;Detailed connection information for forensic analysis&lt;/li&gt;
&lt;li&gt;Integration with existing security monitoring systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔄 Updates and Maintenance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Automatic Updates
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update from repository&lt;/span&gt;
git pull origin main
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./install.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Manual Updates
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create backup&lt;/span&gt;
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; /opt/ssh-alert /opt/ssh-alert.backup
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /etc/ssh-alert/config.conf /etc/ssh-alert/config.conf.backup

&lt;span class="c"&gt;# Update files&lt;/span&gt;
&lt;span class="nb"&gt;sudo cp &lt;/span&gt;ssh-alert-enhanced.sh /opt/ssh-alert/
&lt;span class="nb"&gt;sudo cp &lt;/span&gt;key-parser.py /opt/ssh-alert/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🗑️ Uninstallation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Complete removal&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; /opt/ssh-alert/uninstall.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🤝 Contributing
&lt;/h2&gt;

&lt;p&gt;We welcome contributions! The project is open source and actively maintained.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fork the repository&lt;/li&gt;
&lt;li&gt;Create a feature branch&lt;/li&gt;
&lt;li&gt;Make your changes&lt;/li&gt;
&lt;li&gt;Submit a pull request&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  📚 Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository&lt;/strong&gt;: &lt;a href="https://github.com/B4DCATs/ssh-login-alert" rel="noopener noreferrer"&gt;https://github.com/B4DCATs/ssh-login-alert&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation&lt;/strong&gt;: Complete setup guide in README&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Issues&lt;/strong&gt;: Report bugs or request features&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;License&lt;/strong&gt;: MIT&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🎉 Conclusion
&lt;/h2&gt;

&lt;p&gt;SSH Alert provides a robust, easy-to-use solution for SSH connection monitoring. With its real-time Telegram notifications, flexible configuration, and comprehensive logging, it's an essential tool for any system administrator concerned with server security.&lt;/p&gt;

&lt;p&gt;The combination of detailed user identification, smart rate limiting, and support for automated systems makes it suitable for both small teams and large enterprise environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to enhance your server security?&lt;/strong&gt; Give SSH Alert a try and never miss an SSH connection again!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Have you implemented SSH monitoring in your infrastructure? Share your experiences and tips in the comments below!&lt;/em&gt; 🚀&lt;/p&gt;

</description>
      <category>devops</category>
      <category>security</category>
      <category>opensource</category>
      <category>automation</category>
    </item>
    <item>
      <title>Руководство Python-разработчика по управлению фоновыми процессами</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Mon, 29 Sep 2025 17:22:37 +0000</pubDate>
      <link>https://dev.to/mrvi0/rukovodstvo-python-razrabotchika-po-upravlieniiu-fonovymi-protsiessami-213a</link>
      <guid>https://dev.to/mrvi0/rukovodstvo-python-razrabotchika-po-upravlieniiu-fonovymi-protsiessami-213a</guid>
      <description>&lt;p&gt;Как Python-разработчик, вы наверняка сталкивались с такой ситуацией: вы создали отличного бота, API или скрипт для обработки данных, но поддерживать его работу 24/7 — это кошмар. SSH-сессии обрываются, скрипты падают, серверы перезагружаются, и ваша тщательно продуманная автоматизация внезапно оказывается недоступной.&lt;/p&gt;

&lt;p&gt;В этом подробном руководстве мы рассмотрим различные подходы к запуску Python-приложений в фоновом режиме — от простых решений для разработки до готовых к продакшену систем управления процессами.&lt;/p&gt;

&lt;h2&gt;
  
  
  Проблема с "просто запуском Python"
&lt;/h2&gt;

&lt;p&gt;При локальной разработке вы запускаете скрипты так:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python my_awesome_bot.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Но в продакшене этот подход не работает, потому что:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Разрывы SSH-соединений убивают ваш процесс&lt;/li&gt;
&lt;li&gt;Падения скриптов требуют ручного вмешательства&lt;/li&gt;
&lt;li&gt;Перезагрузки сервера теряют все запущенные процессы&lt;/li&gt;
&lt;li&gt;Управление несколькими ботами становится хаотичным&lt;/li&gt;
&lt;li&gt;Нет видимости того, что действительно работает&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Давайте исправим это с помощью правильного управления процессами.&lt;/p&gt;

&lt;h2&gt;
  
  
  Метод 1: Screen — решение для разработки
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Screen&lt;/strong&gt; идеально подходит для разработки и тестирования. Он создает постоянные терминальные сессии, которые переживают разрывы SSH-соединений.&lt;/p&gt;

&lt;h3&gt;
  
  
  Начало работы с Screen
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Установка screen&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;screen  &lt;span class="c"&gt;# Ubuntu/Debian&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;screen  &lt;span class="c"&gt;# CentOS/RHEL&lt;/span&gt;

&lt;span class="c"&gt;# Запуск новой сессии&lt;/span&gt;
screen

&lt;span class="c"&gt;# Активация виртуального окружения&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ./venv/bin/activate

&lt;span class="c"&gt;# Запуск скрипта&lt;/span&gt;
python my_bot.py

&lt;span class="c"&gt;# Отключение (Ctrl+A, затем D)&lt;/span&gt;
&lt;span class="c"&gt;# Ваш скрипт продолжает работать!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Управление сессиями Screen
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Список всех сессий&lt;/span&gt;
screen &lt;span class="nt"&gt;-ls&lt;/span&gt;

&lt;span class="c"&gt;# Подключение к сессии&lt;/span&gt;
screen &lt;span class="nt"&gt;-r&lt;/span&gt; session_name

&lt;span class="c"&gt;# Завершение сессии (изнутри screen)&lt;/span&gt;
&lt;span class="c"&gt;# Ctrl+A, затем K&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Когда использовать Screen:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Разработка и тестирование&lt;/li&gt;
&lt;li&gt;✅ Быстрые одноразовые скрипты&lt;/li&gt;
&lt;li&gt;✅ Когда нужен доступ к терминалу&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ограничения:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Нет автоматического перезапуска при падениях&lt;/li&gt;
&lt;li&gt;❌ Ручное управление процессами&lt;/li&gt;
&lt;li&gt;❌ Сессии могут потеряться при перезагрузке сервера&lt;/li&gt;
&lt;li&gt;❌ Нет встроенного мониторинга&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Метод 2: Systemd — подход системных сервисов
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Systemd&lt;/strong&gt; — это менеджер служб Linux, идеально подходящий для продакшен-сред, где нужны гарантированный запуск и возможности перезапуска.&lt;/p&gt;

&lt;h3&gt;
  
  
  Создание службы Systemd
&lt;/h3&gt;

&lt;p&gt;Создайте файл службы:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/systemd/system/mybot.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Добавьте эту конфигурацию:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Unit]&lt;/span&gt;
&lt;span class="py"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;My Python Bot Service&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;network.target&lt;/span&gt;

&lt;span class="nn"&gt;[Service]&lt;/span&gt;
&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;idle&lt;/span&gt;
&lt;span class="py"&gt;Restart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;always&lt;/span&gt;
&lt;span class="py"&gt;RestartSec&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;
&lt;span class="py"&gt;User&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;myuser&lt;/span&gt;
&lt;span class="py"&gt;WorkingDirectory&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/home/myuser/bot&lt;/span&gt;
&lt;span class="py"&gt;ExecStart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/home/myuser/bot/venv/bin/python /home/myuser/bot/my_bot.py&lt;/span&gt;
&lt;span class="py"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;PATH=/home/myuser/bot/venv/bin&lt;/span&gt;

&lt;span class="nn"&gt;[Install]&lt;/span&gt;
&lt;span class="py"&gt;WantedBy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;multi-user.target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Управление службой
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Перезагрузка конфигурации systemd&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload

&lt;span class="c"&gt;# Включение автозапуска при загрузке&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;mybot.service

&lt;span class="c"&gt;# Запуск службы&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start mybot.service

&lt;span class="c"&gt;# Проверка статуса&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status mybot.service

&lt;span class="c"&gt;# Просмотр логов&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;journalctl &lt;span class="nt"&gt;-u&lt;/span&gt; mybot.service &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Остановка службы&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl stop mybot.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Когда использовать Systemd:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Продакшен-серверы&lt;/li&gt;
&lt;li&gt;✅ Критически важные службы, которые должны пережить перезагрузки&lt;/li&gt;
&lt;li&gt;✅ Системная интеграция&lt;/li&gt;
&lt;li&gt;✅ Когда нужен детальный контроль&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ограничения:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Требует root-доступа&lt;/li&gt;
&lt;li&gt;❌ Сложная конфигурация&lt;/li&gt;
&lt;li&gt;❌ Системное управление&lt;/li&gt;
&lt;li&gt;❌ Нет встроенного мониторинга процессов&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Метод 3: Современные менеджеры процессов — Python-путь
&lt;/h2&gt;

&lt;p&gt;Для Python-разработчиков есть лучший способ: &lt;strong&gt;Pyker&lt;/strong&gt; — менеджер процессов, созданный специально для Python-приложений.&lt;/p&gt;

&lt;h3&gt;
  
  
  Почему Pyker?
&lt;/h3&gt;

&lt;p&gt;Pyker сочетает простоту screen с мощностью systemd, но разработан специально для Python-воркфлоу:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python-нативный&lt;/strong&gt;: Создан для Python-разработчиков, Python-разработчиками&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Поддержка виртуальных окружений&lt;/strong&gt;: Нативная интеграция с venv/conda&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Нулевая конфигурация&lt;/strong&gt;: Работает из коробки&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Красивый мониторинг&lt;/strong&gt;: Таблицы процессов в реальном времени&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Установка в пользовательском пространстве&lt;/strong&gt;: Не требует root-доступа&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Установка
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Установка одной командой&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/pyker/main/install.sh | bash

&lt;span class="c"&gt;# Или с Python-установщиком&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/pyker/main/install.py | python3

&lt;span class="c"&gt;# Ручная установка&lt;/span&gt;
git clone https://github.com/mrvi0/pyker.git
&lt;span class="nb"&gt;cd &lt;/span&gt;pyker
python3 install.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Базовое использование
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Запуск простого скрипта&lt;/span&gt;
pyker start mybot my_bot.py

&lt;span class="c"&gt;# Запуск с виртуальным окружением&lt;/span&gt;
pyker start webapp app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv

&lt;span class="c"&gt;# Список всех процессов&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# Просмотр логов в реальном времени&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Получение детальной информации о процессе&lt;/span&gt;
pyker info mybot

&lt;span class="c"&gt;# Перезапуск процесса&lt;/span&gt;
pyker restart mybot

&lt;span class="c"&gt;# Остановка процесса&lt;/span&gt;
pyker stop mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Продвинутые возможности
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Автоперезапуск при падениях:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start critical-service app.py &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Поддержка виртуальных окружений:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Работает с любыми Python-окружениями&lt;/span&gt;
pyker start ml-worker train.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /path/to/conda/envs/pytorch
pyker start webapp app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
pyker start data-processor process.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /home/user/projects/venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Мониторинг процессов:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Показывает красивую, адаптивную таблицу с:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Статусом процесса (✓ работает, ✗ остановлен, ⚠ ошибка)&lt;/li&gt;
&lt;li&gt;Использованием CPU и памяти в реальном времени&lt;/li&gt;
&lt;li&gt;Временем запуска/остановки&lt;/li&gt;
&lt;li&gt;Информацией о виртуальном окружении&lt;/li&gt;
&lt;li&gt;Путями к скриптам&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Логи в реальном времени:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;        &lt;span class="c"&gt;# Следование логам в реальном времени&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-n&lt;/span&gt; 100    &lt;span class="c"&gt;# Показать последние 100 строк&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Детальная информация о процессе:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker info mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Показывает исчерпывающую информацию, включая:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Путь к виртуальному окружению и исполняемому файлу Python&lt;/li&gt;
&lt;li&gt;Использование ресурсов (CPU, память)&lt;/li&gt;
&lt;li&gt;Информацию о времени выполнения&lt;/li&gt;
&lt;li&gt;Расположение файла логов&lt;/li&gt;
&lt;li&gt;Статус автоперезапуска&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Автодополнение:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker &amp;lt;TAB&amp;gt;                &lt;span class="c"&gt;# Показывает доступные команды&lt;/span&gt;
pyker stop &amp;lt;TAB&amp;gt;           &lt;span class="c"&gt;# Дополняет именами запущенных процессов&lt;/span&gt;
pyker start app script.py &lt;span class="nt"&gt;--&lt;/span&gt;&amp;lt;TAB&amp;gt;  &lt;span class="c"&gt;# Показывает --venv, --auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Реальные примеры
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Управление Discord-ботами
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Традиционный подход с screen&lt;/span&gt;
screen
&lt;span class="nb"&gt;source&lt;/span&gt; ./venv/bin/activate
python discord_bot.py
&lt;span class="c"&gt;# Ctrl+A, D&lt;/span&gt;

&lt;span class="c"&gt;# С Pyker&lt;/span&gt;
pyker start discord-bot discord_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
pyker logs discord-bot &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Развертывание веб-API
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# С systemd (сложная настройка)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/systemd/system/api.service
&lt;span class="c"&gt;# ... сложная конфигурация ...&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;api.service

&lt;span class="c"&gt;# С Pyker (просто)&lt;/span&gt;
pyker start api app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Пайплайн обработки данных
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Несколько связанных процессов&lt;/span&gt;
pyker start scraper scraper.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env
pyker start processor process_data.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env  
pyker start uploader upload_to_s3.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env

&lt;span class="c"&gt;# Мониторинг всех процессов&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# Проверка конкретного процесса&lt;/span&gt;
pyker info scraper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Воркфлоу машинного обучения
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Обучение с правильным окружением&lt;/span&gt;
pyker start training train_model.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /opt/conda/envs/pytorch &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;

&lt;span class="c"&gt;# Сервис инференса&lt;/span&gt;
pyker start inference inference_server.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./ml-env

&lt;span class="c"&gt;# Предобработка данных&lt;/span&gt;
pyker start preprocess preprocess_data.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Сравнение: выбор правильного метода
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Метод&lt;/th&gt;
&lt;th&gt;Сложность&lt;/th&gt;
&lt;th&gt;Автоперезапуск&lt;/th&gt;
&lt;th&gt;Вирт. окружения&lt;/th&gt;
&lt;th&gt;Мониторинг&lt;/th&gt;
&lt;th&gt;Лучше всего для&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Screen&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Низкая&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Ручной&lt;/td&gt;
&lt;td&gt;Базовый&lt;/td&gt;
&lt;td&gt;Разработка, тестирование&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Systemd&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Высокая&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Ручной&lt;/td&gt;
&lt;td&gt;Системные логи&lt;/td&gt;
&lt;td&gt;Продакшен-серверы&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pyker&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Низкая&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Нативный&lt;/td&gt;
&lt;td&gt;Встроенный&lt;/td&gt;
&lt;td&gt;Python-приложения&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Лучшие практики для продакшена
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Всегда используйте виртуальные окружения
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Создание и активация окружения&lt;/span&gt;
python &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv
&lt;span class="nb"&gt;source &lt;/span&gt;venv/bin/activate
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Запуск с Pyker&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Включайте автоперезапуск для критических служб
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start critical-service app.py &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Реализуйте правильное логирование
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="c1"&gt;# Настройка логирования
&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;basicConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%(asctime)s - %(name)s - %(levelname)s - %(message)s&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;handlers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StreamHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FileHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;app.log&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Приложение запущено&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Логика вашего приложения
&lt;/span&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ошибка приложения: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Обрабатывайте корректные завершения
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;

&lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;signal_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Получен сигнал завершения, очистка...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Код очистки здесь
&lt;/span&gt;    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Регистрация обработчиков сигналов
&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SIGINT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal_handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SIGTERM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal_handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Мониторьте ваши процессы
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Регулярные проверки статуса&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# Мониторинг логов&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Проверка системных ресурсов&lt;/span&gt;
htop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Решение типичных проблем
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Процесс не запускается
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Сначала протестируйте скрипт вручную&lt;/span&gt;
python my_bot.py

&lt;span class="c"&gt;# Проверьте логи Pyker&lt;/span&gt;
pyker logs mybot

&lt;span class="c"&gt;# Проверьте информацию о процессе&lt;/span&gt;
pyker info mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Проблемы с виртуальными окружениями
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Убедитесь, что путь к venv существует&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; ./venv/bin/python

&lt;span class="c"&gt;# Протестируйте с абсолютным путем&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /полный/путь/к/venv

&lt;span class="c"&gt;# Проверьте исполняемый файл Python&lt;/span&gt;
./venv/bin/python &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Высокое использование ресурсов
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Мониторинг использования ресурсов&lt;/span&gt;
pyker list  &lt;span class="c"&gt;# Показывает колонки CPU и памяти&lt;/span&gt;

&lt;span class="c"&gt;# Проверка системных ресурсов&lt;/span&gt;
htop
top

&lt;span class="c"&gt;# Завершение проблемных процессов&lt;/span&gt;
pyker stop process_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Управление логами
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Просмотр файлов логов напрямую&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; ~/.pyker/logs/

&lt;span class="c"&gt;# Очистка старых логов&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; ~/.pyker/logs/&lt;span class="k"&gt;*&lt;/span&gt;.log.&lt;span class="k"&gt;*&lt;/span&gt;

&lt;span class="c"&gt;# Настройка ротации логов&lt;/span&gt;
nano ~/.pyker/config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Соображения безопасности
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Права пользователей
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Запуск от имени пользователя без root&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv

&lt;span class="c"&gt;# Проверка владельца процесса&lt;/span&gt;
ps aux | &lt;span class="nb"&gt;grep &lt;/span&gt;mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Переменные окружения
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Установка переменных окружения&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-secret-key"&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Сетевая безопасность
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Привязка только к localhost&lt;/span&gt;
pyker start api app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;span class="c"&gt;# Настройте ваше приложение для привязки к 127.0.0.1:8000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Заключение
&lt;/h2&gt;

&lt;p&gt;Запуск Python-приложений в продакшене не должен быть сложным. Ключ в выборе правильного инструмента для ваших нужд:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Разработка/Тестирование&lt;/strong&gt;: Используйте Screen для быстрого тестирования&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Системные службы&lt;/strong&gt;: Используйте Systemd для критически важных системных служб&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python-приложения&lt;/strong&gt;: Используйте Pyker для современного управления Python-процессами&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pyker&lt;/strong&gt; предлагает идеальный баланс простоты и мощности для Python-разработчиков. Он создан специально для Python-воркфлоу, нативно поддерживает виртуальные окружения и предоставляет красивый мониторинг без сложности systemd.&lt;/p&gt;

&lt;p&gt;Лучшая часть? Вы можете начать просто и масштабироваться. Начните с Screen для разработки, затем переходите к Pyker для продакшена, и используйте Systemd только когда нужна глубокая системная интеграция.&lt;/p&gt;

&lt;p&gt;Ваши Python-приложения заслуживают лучшего, чем ручные перезапуски и SSH-сессии. Выберите правильный инструмент, и пусть ваш код работает надежно 24/7.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Какой у вас опыт запуска Python-приложений в продакшене? Пробовали ли вы какие-либо из этих подходов? Поделитесь своими мыслями в комментариях ниже!&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  python #devops #processmanagement #automation #production #linux #systemd #backgroundprocesses
&lt;/h1&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Python Developer's Guide to Background Process Management</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Mon, 29 Sep 2025 17:19:12 +0000</pubDate>
      <link>https://dev.to/mrvi0/the-python-developers-guide-to-background-process-management-1f6c</link>
      <guid>https://dev.to/mrvi0/the-python-developers-guide-to-background-process-management-1f6c</guid>
      <description>&lt;p&gt;As a Python developer, you've probably faced this scenario: you've built an amazing bot, API, or data processing script, but keeping it running 24/7 is a nightmare. SSH sessions disconnect, scripts crash, servers reboot, and suddenly your carefully crafted automation is offline.&lt;/p&gt;

&lt;p&gt;In this comprehensive guide, we'll explore different approaches to running Python applications in the background, from simple development solutions to production-ready process management.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with "Just Running Python"
&lt;/h2&gt;

&lt;p&gt;When you develop locally, you run scripts like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python my_awesome_bot.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But in production, this approach fails because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSH disconnections kill your process&lt;/li&gt;
&lt;li&gt;Script crashes require manual intervention
&lt;/li&gt;
&lt;li&gt;Server reboots lose all running processes&lt;/li&gt;
&lt;li&gt;Managing multiple bots becomes chaotic&lt;/li&gt;
&lt;li&gt;No visibility into what's actually running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's fix this with proper process management.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 1: Screen - The Development Solution
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Screen&lt;/strong&gt; is perfect for development and testing. It creates persistent terminal sessions that survive SSH disconnections.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Started with Screen
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install screen&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;screen  &lt;span class="c"&gt;# Ubuntu/Debian&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;screen  &lt;span class="c"&gt;# CentOS/RHEL&lt;/span&gt;

&lt;span class="c"&gt;# Start a new session&lt;/span&gt;
screen

&lt;span class="c"&gt;# Activate your virtual environment&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; ./venv/bin/activate

&lt;span class="c"&gt;# Run your script&lt;/span&gt;
python my_bot.py

&lt;span class="c"&gt;# Detach (Ctrl+A, then D)&lt;/span&gt;
&lt;span class="c"&gt;# Your script keeps running!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Managing Screen Sessions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List all sessions&lt;/span&gt;
screen &lt;span class="nt"&gt;-ls&lt;/span&gt;

&lt;span class="c"&gt;# Reattach to a session&lt;/span&gt;
screen &lt;span class="nt"&gt;-r&lt;/span&gt; session_name

&lt;span class="c"&gt;# Kill a session (from within screen)&lt;/span&gt;
&lt;span class="c"&gt;# Ctrl+A, then K&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use Screen:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Development and testing&lt;/li&gt;
&lt;li&gt;✅ Quick one-off scripts&lt;/li&gt;
&lt;li&gt;✅ When you need terminal access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ No automatic restart on crashes&lt;/li&gt;
&lt;li&gt;❌ Manual process management&lt;/li&gt;
&lt;li&gt;❌ Sessions can be lost on server reboot&lt;/li&gt;
&lt;li&gt;❌ No built-in monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Method 2: Systemd - The System Service Approach
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Systemd&lt;/strong&gt; is Linux's service manager, perfect for production environments where you need guaranteed startup and restart capabilities.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Systemd Service
&lt;/h3&gt;

&lt;p&gt;Create a service file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/systemd/system/mybot.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Unit]&lt;/span&gt;
&lt;span class="py"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;My Python Bot Service&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;network.target&lt;/span&gt;

&lt;span class="nn"&gt;[Service]&lt;/span&gt;
&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;idle&lt;/span&gt;
&lt;span class="py"&gt;Restart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;always&lt;/span&gt;
&lt;span class="py"&gt;RestartSec&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;3&lt;/span&gt;
&lt;span class="py"&gt;User&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;myuser&lt;/span&gt;
&lt;span class="py"&gt;WorkingDirectory&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/home/myuser/bot&lt;/span&gt;
&lt;span class="py"&gt;ExecStart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/home/myuser/bot/venv/bin/python /home/myuser/bot/my_bot.py&lt;/span&gt;
&lt;span class="py"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;PATH=/home/myuser/bot/venv/bin&lt;/span&gt;

&lt;span class="nn"&gt;[Install]&lt;/span&gt;
&lt;span class="py"&gt;WantedBy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;multi-user.target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Managing the Service
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Reload systemd configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload

&lt;span class="c"&gt;# Enable auto-start on boot&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;mybot.service

&lt;span class="c"&gt;# Start the service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start mybot.service

&lt;span class="c"&gt;# Check status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status mybot.service

&lt;span class="c"&gt;# View logs&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;journalctl &lt;span class="nt"&gt;-u&lt;/span&gt; mybot.service &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Stop the service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl stop mybot.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use Systemd:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Production servers&lt;/li&gt;
&lt;li&gt;✅ Critical services that must survive reboots&lt;/li&gt;
&lt;li&gt;✅ System-level integration&lt;/li&gt;
&lt;li&gt;✅ When you need fine-grained control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Requires root access&lt;/li&gt;
&lt;li&gt;❌ Complex configuration&lt;/li&gt;
&lt;li&gt;❌ System-level management&lt;/li&gt;
&lt;li&gt;❌ No built-in process monitoring&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Method 3: Modern Process Managers - The Python Way
&lt;/h2&gt;

&lt;p&gt;For Python developers, there's a better way: &lt;strong&gt;Pyker&lt;/strong&gt; - a process manager built specifically for Python applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Pyker?
&lt;/h3&gt;

&lt;p&gt;Pyker combines the simplicity of screen with the power of systemd, but designed specifically for Python workflows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python-native&lt;/strong&gt;: Built for Python developers, by Python developers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Virtual environment support&lt;/strong&gt;: Native venv/conda integration&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero configuration&lt;/strong&gt;: Works out of the box&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Beautiful monitoring&lt;/strong&gt;: Real-time process tables&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User-space installation&lt;/strong&gt;: No root access required&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# One-line installation&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/pyker/main/install.sh | bash

&lt;span class="c"&gt;# Or with Python installer&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/pyker/main/install.py | python3

&lt;span class="c"&gt;# Manual installation&lt;/span&gt;
git clone https://github.com/mrvi0/pyker.git
&lt;span class="nb"&gt;cd &lt;/span&gt;pyker
python3 install.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basic Usage
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a simple script&lt;/span&gt;
pyker start mybot my_bot.py

&lt;span class="c"&gt;# Start with virtual environment&lt;/span&gt;
pyker start webapp app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv

&lt;span class="c"&gt;# List all processes&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# View logs in real-time&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Get detailed process information&lt;/span&gt;
pyker info mybot

&lt;span class="c"&gt;# Restart a process&lt;/span&gt;
pyker restart mybot

&lt;span class="c"&gt;# Stop a process&lt;/span&gt;
pyker stop mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Advanced Features
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Auto-restart on failure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start critical-service app.py &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Virtual environment support:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Works with any Python environment&lt;/span&gt;
pyker start ml-worker train.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /path/to/conda/envs/pytorch
pyker start webapp app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
pyker start data-processor process.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /home/user/projects/venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Process monitoring:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows a beautiful, adaptive table with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process status (✓ running, ✗ stopped, ⚠ error)&lt;/li&gt;
&lt;li&gt;Real-time CPU and memory usage&lt;/li&gt;
&lt;li&gt;Start/stop times&lt;/li&gt;
&lt;li&gt;Virtual environment information&lt;/li&gt;
&lt;li&gt;Script paths&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-time logs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;        &lt;span class="c"&gt;# Follow logs in real-time&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-n&lt;/span&gt; 100    &lt;span class="c"&gt;# Show last 100 lines&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Detailed process information:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker info mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shows comprehensive information including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Virtual environment path and Python executable&lt;/li&gt;
&lt;li&gt;Resource usage (CPU, memory)&lt;/li&gt;
&lt;li&gt;Runtime information&lt;/li&gt;
&lt;li&gt;Log file location&lt;/li&gt;
&lt;li&gt;Auto-restart status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tab completion:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker &amp;lt;TAB&amp;gt;                &lt;span class="c"&gt;# Shows available commands&lt;/span&gt;
pyker stop &amp;lt;TAB&amp;gt;           &lt;span class="c"&gt;# Completes with running process names&lt;/span&gt;
pyker start app script.py &lt;span class="nt"&gt;--&lt;/span&gt;&amp;lt;TAB&amp;gt;  &lt;span class="c"&gt;# Shows --venv, --auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-World Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Discord Bot Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Traditional approach with screen&lt;/span&gt;
screen
&lt;span class="nb"&gt;source&lt;/span&gt; ./venv/bin/activate
python discord_bot.py
&lt;span class="c"&gt;# Ctrl+A, D&lt;/span&gt;

&lt;span class="c"&gt;# With Pyker&lt;/span&gt;
pyker start discord-bot discord_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
pyker logs discord-bot &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Web API Deployment
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# With systemd (complex setup)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/systemd/system/api.service
&lt;span class="c"&gt;# ... complex configuration ...&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;api.service

&lt;span class="c"&gt;# With Pyker (simple)&lt;/span&gt;
pyker start api app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Data Processing Pipeline
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Multiple related processes&lt;/span&gt;
pyker start scraper scraper.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env
pyker start processor process_data.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env  
pyker start uploader upload_to_s3.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env

&lt;span class="c"&gt;# Monitor all processes&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# Check specific process&lt;/span&gt;
pyker info scraper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Machine Learning Workflows
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Training with proper environment&lt;/span&gt;
pyker start training train_model.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /opt/conda/envs/pytorch &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;

&lt;span class="c"&gt;# Inference service&lt;/span&gt;
pyker start inference inference_server.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./ml-env

&lt;span class="c"&gt;# Data preprocessing&lt;/span&gt;
pyker start preprocess preprocess_data.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./data-env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Comparison: Choosing the Right Method
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Complexity&lt;/th&gt;
&lt;th&gt;Auto-restart&lt;/th&gt;
&lt;th&gt;Virtual Env&lt;/th&gt;
&lt;th&gt;Monitoring&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Screen&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;Basic&lt;/td&gt;
&lt;td&gt;Development, testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Systemd&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Manual&lt;/td&gt;
&lt;td&gt;System logs&lt;/td&gt;
&lt;td&gt;Production servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pyker&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;Native&lt;/td&gt;
&lt;td&gt;Built-in&lt;/td&gt;
&lt;td&gt;Python applications&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Best Practices for Production
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Always Use Virtual Environments
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create and activate environment&lt;/span&gt;
python &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv
&lt;span class="nb"&gt;source &lt;/span&gt;venv/bin/activate
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Run with Pyker&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Enable Auto-restart for Critical Services
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start critical-service app.py &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Implement Proper Logging
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="c1"&gt;# Configure logging
&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;basicConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%(asctime)s - %(name)s - %(levelname)s - %(message)s&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;handlers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StreamHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FileHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;app.log&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Application started&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Your application logic
&lt;/span&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Application error: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Handle Graceful Shutdowns
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;

&lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;signal_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Received shutdown signal, cleaning up...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Cleanup code here
&lt;/span&gt;    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Register signal handlers
&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SIGINT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal_handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SIGTERM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;signal_handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Monitor Your Processes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Regular status checks&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# Monitor logs&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Check system resources&lt;/span&gt;
htop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting Common Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Process Won't Start
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Test the script manually first&lt;/span&gt;
python my_bot.py

&lt;span class="c"&gt;# Check Pyker logs&lt;/span&gt;
pyker logs mybot

&lt;span class="c"&gt;# Verify process information&lt;/span&gt;
pyker info mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Virtual Environment Issues
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Verify venv path exists&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; ./venv/bin/python

&lt;span class="c"&gt;# Test with absolute path&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /full/path/to/venv

&lt;span class="c"&gt;# Check Python executable&lt;/span&gt;
./venv/bin/python &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  High Resource Usage
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Monitor resource usage&lt;/span&gt;
pyker list  &lt;span class="c"&gt;# Shows CPU and memory columns&lt;/span&gt;

&lt;span class="c"&gt;# Check system resources&lt;/span&gt;
htop
top

&lt;span class="c"&gt;# Kill problematic processes&lt;/span&gt;
pyker stop process_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Log Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# View log files directly&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; ~/.pyker/logs/

&lt;span class="c"&gt;# Clean old logs&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; ~/.pyker/logs/&lt;span class="k"&gt;*&lt;/span&gt;.log.&lt;span class="k"&gt;*&lt;/span&gt;

&lt;span class="c"&gt;# Configure log rotation&lt;/span&gt;
nano ~/.pyker/config.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  User Permissions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run as non-root user&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv

&lt;span class="c"&gt;# Check process ownership&lt;/span&gt;
ps aux | &lt;span class="nb"&gt;grep &lt;/span&gt;mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Environment Variables
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Set environment variables&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-secret-key"&lt;/span&gt;
pyker start mybot my_bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Network Security
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Bind to localhost only&lt;/span&gt;
pyker start api app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;span class="c"&gt;# Configure your app to bind to 127.0.0.1:8000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Running Python applications in production doesn't have to be complicated. The key is choosing the right tool for your needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Development/Testing&lt;/strong&gt;: Use Screen for quick testing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;System Services&lt;/strong&gt;: Use Systemd for critical system services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python Applications&lt;/strong&gt;: Use Pyker for modern Python process management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pyker&lt;/strong&gt; offers the perfect balance of simplicity and power for Python developers. It's designed specifically for Python workflows, supports virtual environments natively, and provides beautiful monitoring without the complexity of systemd.&lt;/p&gt;

&lt;p&gt;The best part? You can start simple and scale up. Begin with Screen for development, then move to Pyker for production, and only use Systemd when you need deep system integration.&lt;/p&gt;

&lt;p&gt;Your Python applications deserve better than manual restarts and SSH sessions. Choose the right tool, and let your code run reliably 24/7.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What's your experience with running Python applications in production? Have you tried any of these approaches? Share your thoughts in the comments below!&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  python #devops #processmanagement #automation #production #linux #systemd #backgroundprocesses
&lt;/h1&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Monitoring OpenVPN with Prometheus and Grafana: A Complete Guide</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Sat, 27 Sep 2025 05:53:42 +0000</pubDate>
      <link>https://dev.to/mrvi0/monitoring-openvpn-with-prometheus-and-grafana-a-complete-guide-5418</link>
      <guid>https://dev.to/mrvi0/monitoring-openvpn-with-prometheus-and-grafana-a-complete-guide-5418</guid>
      <description>&lt;h2&gt;
  
  
  Why Monitor OpenVPN?
&lt;/h2&gt;

&lt;p&gt;OpenVPN is one of the most popular VPN solutions, but monitoring VPN connections can be challenging. Without proper monitoring, you might not notice when clients are having connection issues, when traffic patterns change, or when your VPN server is under stress.&lt;/p&gt;

&lt;p&gt;In this guide, we'll set up comprehensive monitoring for OpenVPN using Prometheus and Grafana, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real-time client connection tracking&lt;/li&gt;
&lt;li&gt;Traffic statistics and bandwidth monitoring&lt;/li&gt;
&lt;li&gt;Security alerts and access control&lt;/li&gt;
&lt;li&gt;Beautiful dashboards for visualization&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Challenge: OpenVPN Status Files
&lt;/h2&gt;

&lt;p&gt;OpenVPN provides status information through text files, but these aren't designed for modern monitoring systems. The status files contain client information, traffic statistics, and connection details, but you need a way to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Parse these files regularly&lt;/li&gt;
&lt;li&gt;Convert the data to metrics format&lt;/li&gt;
&lt;li&gt;Expose metrics to Prometheus&lt;/li&gt;
&lt;li&gt;Visualize the data in Grafana&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Solution: OpenVPN Prometheus Exporter
&lt;/h2&gt;

&lt;p&gt;We'll use an open-source OpenVPN Prometheus Exporter that solves these challenges by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading OpenVPN status files automatically&lt;/li&gt;
&lt;li&gt;Converting data to Prometheus metrics format&lt;/li&gt;
&lt;li&gt;Providing security features like IP-based access control&lt;/li&gt;
&lt;li&gt;Including a ready-to-use Grafana dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Setting Up OpenVPN Server
&lt;/h2&gt;

&lt;p&gt;First, ensure your OpenVPN server is configured to write status files. If you don't have OpenVPN set up yet, I recommend using the excellent &lt;a href="https://github.com/angristan/openvpn-install" rel="noopener noreferrer"&gt;openvpn-install script&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
&lt;span class="nb"&gt;chmod&lt;/span&gt; +x openvpn-install.sh
./openvpn-install.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this to your OpenVPN server configuration to enable status logging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add to /etc/openvpn/server.conf&lt;/span&gt;
status /var/log/openvpn/status.log 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The status file will be updated every 30 seconds with client information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Deploying the Exporter
&lt;/h2&gt;

&lt;p&gt;The easiest way to deploy the exporter is using Docker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download docker-compose.yml&lt;/span&gt;
curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://raw.githubusercontent.com/B4DCATs/openvpn_exporter/main/docker-compose.yml

&lt;span class="c"&gt;# Start the exporter&lt;/span&gt;
docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use the one-command setup script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sSL&lt;/span&gt; https://raw.githubusercontent.com/B4DCATs/openvpn_exporter/main/quick-start.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exporter will be available at &lt;code&gt;http://localhost:9176/metrics&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Security Configuration
&lt;/h2&gt;

&lt;p&gt;For production environments, restrict metrics access to specific IPs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# docker-compose.yml&lt;/span&gt;
&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALLOWED_IPS=192.168.1.100,10.0.0.50,monitoring-server.local&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures only your monitoring infrastructure can access the metrics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Prometheus Configuration
&lt;/h2&gt;

&lt;p&gt;Add the exporter to your Prometheus configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# prometheus.yml&lt;/span&gt;
&lt;span class="na"&gt;scrape_configs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;openvpn-exporter'&lt;/span&gt;
    &lt;span class="na"&gt;static_configs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;targets&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;your-server:9176'&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;scrape_interval&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;30s&lt;/span&gt;
    &lt;span class="na"&gt;metrics_path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/metrics&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Grafana Dashboard
&lt;/h2&gt;

&lt;p&gt;Import the included dashboard for immediate visualization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download the dashboard&lt;/span&gt;
curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://raw.githubusercontent.com/B4DCATs/openvpn_exporter/main/dashboard.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Grafana:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to Dashboards → Import&lt;/li&gt;
&lt;li&gt;Upload &lt;code&gt;dashboard.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select your Prometheus datasource&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The dashboard includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client Statistics&lt;/strong&gt;: Connected clients, traffic, connection times&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server Health&lt;/strong&gt;: Server status and availability&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traffic Analysis&lt;/strong&gt;: Bytes sent/received, top users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Monitoring&lt;/strong&gt;: Access control alerts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Metrics to Monitor
&lt;/h2&gt;

&lt;p&gt;Here are the most important metrics to track:&lt;/p&gt;

&lt;h3&gt;
  
  
  Client Connections
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Total connected clients
sum(openvpn_server_client_count)

# Clients by server
openvpn_server_client_count{instance="your-server"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Traffic Analysis
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Top 5 clients by traffic
topk(5, openvpn_server_client_received_bytes_total + openvpn_server_client_sent_bytes_total)

# Traffic rate per client
rate(openvpn_server_client_received_bytes_total[5m])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Connection Duration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# How long clients have been connected
time() - openvpn_server_client_connection_time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting Up Alerts
&lt;/h2&gt;

&lt;p&gt;Create alerts for critical events:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# alert.rules.yml&lt;/span&gt;
&lt;span class="na"&gt;groups&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;openvpn_alerts&lt;/span&gt;
    &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OpenVPNServerDown&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;openvpn_up == &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;critical&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OpenVPN&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;server&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;is&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;down"&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;TooManyClients&lt;/span&gt;
        &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;openvpn_server_client_count &amp;gt; &lt;/span&gt;&lt;span class="m"&gt;100&lt;/span&gt;
        &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2m&lt;/span&gt;
        &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;warning&lt;/span&gt;
        &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Too&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;many&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;OpenVPN&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;clients&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;connected"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Multiple OpenVPN Servers
&lt;/h3&gt;

&lt;p&gt;Monitor multiple servers by updating the status paths:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;STATUS_PATHS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/var/log/openvpn/server1.status,/var/log/openvpn/server2.status"&lt;/span&gt;
docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Service Discovery
&lt;/h3&gt;

&lt;p&gt;Use Prometheus file-based service discovery for dynamic monitoring:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# prometheus.yml&lt;/span&gt;
&lt;span class="na"&gt;scrape_configs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;job_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;openvpn-exporter'&lt;/span&gt;
    &lt;span class="na"&gt;file_sd_configs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;files&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;openvpn-targets.json'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;openvpn-targets.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"targets"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"openvpn-server-1:9176"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"labels"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"instance"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"server-1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"environment"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"production"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Complete Monitoring Stack
&lt;/h2&gt;

&lt;p&gt;For a full monitoring setup, use the complete Docker Compose stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download complete stack&lt;/span&gt;
curl &lt;span class="nt"&gt;-O&lt;/span&gt; https://raw.githubusercontent.com/B4DCATs/openvpn_exporter/main/examples/config/docker-compose.full.yml

&lt;span class="c"&gt;# Start monitoring stack&lt;/span&gt;
docker compose &lt;span class="nt"&gt;-f&lt;/span&gt; docker-compose.full.yml up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenVPN Exporter&lt;/li&gt;
&lt;li&gt;Prometheus&lt;/li&gt;
&lt;li&gt;Grafana&lt;/li&gt;
&lt;li&gt;Pre-configured dashboards and alerts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Access your monitoring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prometheus: &lt;code&gt;http://localhost:9090&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Grafana: &lt;code&gt;http://localhost:3000&lt;/code&gt; (admin/admin)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting Common Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Status File Not Found
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Find your OpenVPN status files&lt;/span&gt;
find /var/log &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*openvpn*"&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f

&lt;span class="c"&gt;# Common locations:&lt;/span&gt;
&lt;span class="c"&gt;# /var/log/openvpn/status.log&lt;/span&gt;
&lt;span class="c"&gt;# /var/log/openvpn/server.status&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  No Metrics Available
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check exporter logs&lt;/span&gt;
docker logs openvpn-exporter

&lt;span class="c"&gt;# Test metrics endpoint&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; http://localhost:9176/metrics | &lt;span class="nb"&gt;grep &lt;/span&gt;openvpn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Access Denied Errors
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check ALLOWED_IPS configuration&lt;/span&gt;
docker logs openvpn-exporter | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Access denied"&lt;/span&gt;

&lt;span class="c"&gt;# Test from allowed IP&lt;/span&gt;
curl &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"X-Forwarded-For: 192.168.1.100"&lt;/span&gt; http://localhost:9176/metrics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Security First&lt;/strong&gt;: Always use IP restrictions in production&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular Monitoring&lt;/strong&gt;: Set up alerts for server downtime and unusual traffic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capacity Planning&lt;/strong&gt;: Monitor client counts and traffic trends&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backup Configuration&lt;/strong&gt;: Keep your monitoring configuration in version control&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation&lt;/strong&gt;: Document your monitoring setup and alert procedures&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Monitoring OpenVPN with Prometheus and Grafana provides valuable insights into your VPN infrastructure. You'll be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Track client connections and usage patterns&lt;/li&gt;
&lt;li&gt;Monitor server health and performance&lt;/li&gt;
&lt;li&gt;Detect security issues and unusual activity&lt;/li&gt;
&lt;li&gt;Plan capacity based on traffic trends&lt;/li&gt;
&lt;li&gt;Troubleshoot connection problems quickly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The OpenVPN Prometheus Exporter makes this setup straightforward with its security features, comprehensive dashboard, and easy deployment options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/B4DCATs/openvpn_exporter" rel="noopener noreferrer"&gt;OpenVPN Prometheus Exporter&lt;/a&gt; - The exporter we used&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://prometheus.io/docs/" rel="noopener noreferrer"&gt;Prometheus Documentation&lt;/a&gt; - Learn more about Prometheus&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://grafana.com/docs/" rel="noopener noreferrer"&gt;Grafana Documentation&lt;/a&gt; - Grafana setup and configuration&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://openvpn.net/community-resources/" rel="noopener noreferrer"&gt;OpenVPN Documentation&lt;/a&gt; - OpenVPN configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start monitoring your OpenVPN infrastructure today and gain the visibility you need to ensure reliable VPN services for your users!&lt;/p&gt;

</description>
      <category>monitoring</category>
      <category>python</category>
      <category>tutorial</category>
      <category>devops</category>
    </item>
    <item>
      <title>ConfWatch: The Configuration File Monitor That Actually Works</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Fri, 05 Sep 2025 18:28:32 +0000</pubDate>
      <link>https://dev.to/mrvi0/confwatch-the-configuration-file-monitor-that-actually-works-4jpp</link>
      <guid>https://dev.to/mrvi0/confwatch-the-configuration-file-monitor-that-actually-works-4jpp</guid>
      <description>&lt;h2&gt;
  
  
  The Problem Every Developer Faces
&lt;/h2&gt;

&lt;p&gt;You know that feeling when you're debugging a server issue at 3 AM, and you realize you changed a config file last week but can't remember what you changed? Or when your colleague asks "what did you modify in the nginx config?" and you're staring at a file that looks completely different from what you remember?&lt;/p&gt;

&lt;p&gt;I've been there. We've all been there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter ConfWatch
&lt;/h2&gt;

&lt;p&gt;ConfWatch is a simple, powerful tool that solves this exact problem. It's like having a time machine for your configuration files.&lt;/p&gt;

&lt;h3&gt;
  
  
  What It Does (In Plain English)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tracks every change&lt;/strong&gt; to your config files automatically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shows you exactly what changed&lt;/strong&gt; with beautiful diffs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lets you go back in time&lt;/strong&gt; to any previous version&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Works in the background&lt;/strong&gt; without you thinking about it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Has a web interface&lt;/strong&gt; so you can see everything in a browser&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why I Built This
&lt;/h3&gt;

&lt;p&gt;I was tired of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manually copying config files before making changes&lt;/li&gt;
&lt;li&gt;Forgetting what I changed and when&lt;/li&gt;
&lt;li&gt;Spending hours debugging issues caused by config changes&lt;/li&gt;
&lt;li&gt;Not having a proper history of my server configurations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I built ConfWatch to solve these problems once and for all.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works (The Simple Version)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install it&lt;/strong&gt; - One command, done&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tell it which files to watch&lt;/strong&gt; - Point it at your configs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Make changes normally&lt;/strong&gt; - It watches in the background&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;See what changed&lt;/strong&gt; - Check the web interface or CLI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rollback if needed&lt;/strong&gt; - One command to go back&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Real-World Example
&lt;/h2&gt;

&lt;p&gt;Let's say you're managing a web server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install ConfWatch&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/conf-watch/main/install.sh | bash

&lt;span class="c"&gt;# Start monitoring your nginx config&lt;/span&gt;
confwatch snapshot /etc/nginx/nginx.conf

&lt;span class="c"&gt;# Make some changes to nginx.conf&lt;/span&gt;
&lt;span class="c"&gt;# ... edit the file ...&lt;/span&gt;

&lt;span class="c"&gt;# See what changed&lt;/span&gt;
confwatch diff /etc/nginx/nginx.conf

&lt;span class="c"&gt;# If something breaks, rollback&lt;/span&gt;
confwatch rollback /etc/nginx/nginx.conf abc1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No complex setup, no learning curve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features That Actually Matter
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Automatic Monitoring
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Watches files for changes automatically&lt;/li&gt;
&lt;li&gt;Creates snapshots when files are modified&lt;/li&gt;
&lt;li&gt;No need to remember to backup before changes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Beautiful Web Interface
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;See all your files and their history&lt;/li&gt;
&lt;li&gt;Click to see diffs between versions&lt;/li&gt;
&lt;li&gt;One-click rollbacks&lt;/li&gt;
&lt;li&gt;Works on any device with a browser&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Command Line Power
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Full CLI for automation and scripting&lt;/li&gt;
&lt;li&gt;Integrates with your existing workflow&lt;/li&gt;
&lt;li&gt;Works great in CI/CD pipelines&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Smart Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Only tracks actual changes (not just file touches)&lt;/li&gt;
&lt;li&gt;Compresses old versions to save space&lt;/li&gt;
&lt;li&gt;Handles multiple files simultaneously&lt;/li&gt;
&lt;li&gt;Secure authentication for web interface&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;h3&gt;
  
  
  For Developers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Never lose track of config changes again&lt;/li&gt;
&lt;li&gt;Debug issues faster with complete change history&lt;/li&gt;
&lt;li&gt;Collaborate better with team members&lt;/li&gt;
&lt;li&gt;Reduce downtime from configuration mistakes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For DevOps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Maintain audit trails for compliance&lt;/li&gt;
&lt;li&gt;Quickly rollback problematic changes&lt;/li&gt;
&lt;li&gt;Monitor configuration drift across servers&lt;/li&gt;
&lt;li&gt;Integrate with existing monitoring tools&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For System Administrators
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Keep track of server configuration changes&lt;/li&gt;
&lt;li&gt;Quickly identify what changed before an outage&lt;/li&gt;
&lt;li&gt;Maintain configuration backups automatically&lt;/li&gt;
&lt;li&gt;Reduce human error in configuration management&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Technical Stuff (If You Care)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Built in Python with a clean, simple architecture&lt;/li&gt;
&lt;li&gt;Uses Git under the hood for version control&lt;/li&gt;
&lt;li&gt;Web interface built with Flask&lt;/li&gt;
&lt;li&gt;Supports both manual and automatic snapshots&lt;/li&gt;
&lt;li&gt;Works on Linux, macOS, and Windows&lt;/li&gt;
&lt;li&gt;Lightweight and fast&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;The installation is literally one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/conf-watch/main/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then start monitoring your files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;confwatch snapshot /path/to/your/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the web interface and you're done.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;ConfWatch solves a real problem that every developer and system administrator faces. It's not another complex tool that requires a PhD to use. It's simple, it works, and it saves you time and headaches.&lt;/p&gt;

&lt;p&gt;If you've ever spent hours debugging a configuration issue, or if you've ever wished you could could see what changed in a config file last week, give ConfWatch a try.&lt;/p&gt;

&lt;p&gt;Your future self will thank you.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/mrvi0/conf-watch" rel="noopener noreferrer"&gt;https://github.com/mrvi0/conf-watch&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Installation&lt;/strong&gt;: &lt;code&gt;curl -fsSL https://raw.githubusercontent.com/mrvi0/conf-watch/main/install.sh | bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you tried ConfWatch? Let me know what you think in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>programming</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Pyker: A Modern PM2 Alternative for Python Developers</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Tue, 19 Aug 2025 00:09:00 +0000</pubDate>
      <link>https://dev.to/mrvi0/pyker-a-modern-pm2-alternative-for-python-developers-e8m</link>
      <guid>https://dev.to/mrvi0/pyker-a-modern-pm2-alternative-for-python-developers-e8m</guid>
      <description>&lt;p&gt;Managing Python scripts in production can be a pain. You start a script, it crashes, you restart it manually, check logs by SSH-ing into servers... Sound familiar? While PM2 solved this for Node.js, Python developers have been stuck with systemd, screen sessions, or complex container setups.&lt;/p&gt;

&lt;p&gt;Meet &lt;strong&gt;Pyker&lt;/strong&gt; - a lightweight, user-friendly process manager built specifically for Python scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 What is Pyker?
&lt;/h2&gt;

&lt;p&gt;Pyker is a command-line tool that lets you start, stop, monitor, and manage Python scripts as background processes. Think PM2, but designed from the ground up for Python with modern features like virtual environment support, adaptive terminal output, and zero-sudo installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a Python script as a background process&lt;/span&gt;
pyker start mybot bot.py

&lt;span class="c"&gt;# List all running processes&lt;/span&gt;
pyker list

&lt;span class="c"&gt;# View real-time logs&lt;/span&gt;
pyker logs mybot &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Process still running after restart? ✅&lt;/span&gt;
pyker restart mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ✨ Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;🐍 Virtual Environment Support&lt;/strong&gt; - Works seamlessly with venv, conda, pipenv&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📊 Beautiful Table Interface&lt;/strong&gt; - Adaptive layout that fits your terminal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🔄 Auto-restart&lt;/strong&gt; - Keep your scripts running even after crashes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;📝 Centralized Logging&lt;/strong&gt; - All process logs in one place with rotation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;⌨️ Tab Completion&lt;/strong&gt; - Smart autocompletion for commands and process names&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🛠️ Simple Installation&lt;/strong&gt; - No sudo required, installs in user space&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;🎯 Cross-platform&lt;/strong&gt; - Linux, macOS, and Windows support&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📦 Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  One-line Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/pyker/main/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Manual Installation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Clone and install&lt;/span&gt;
git clone https://github.com/mrvi0/pyker.git
&lt;span class="nb"&gt;cd &lt;/span&gt;pyker
python3 install.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No sudo required! Pyker installs in your user space (&lt;code&gt;~/.local/bin&lt;/code&gt;) and automatically configures your PATH.&lt;/p&gt;

&lt;h2&gt;
  
  
  🐍 Virtual Environment Magic
&lt;/h2&gt;

&lt;p&gt;One of Pyker's standout features is native virtual environment support. Just point to your venv, and Pyker handles the rest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start with virtual environment&lt;/span&gt;
pyker start webapp app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv

&lt;span class="c"&gt;# Works with any environment type&lt;/span&gt;
pyker start ml-worker train.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /path/to/conda/envs/pytorch

&lt;span class="c"&gt;# Environment info is preserved across restarts&lt;/span&gt;
pyker restart webapp  &lt;span class="c"&gt;# Still uses ./venv automatically&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pyker automatically detects Python executables in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;venv/bin/python&lt;/code&gt; (Linux/macOS)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;venv/Scripts/python.exe&lt;/code&gt; (Windows)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📊 Process Monitoring Made Easy
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;list&lt;/code&gt; command shows all your processes in a beautiful, adaptive table:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9lmvshc98ijpnqiana2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9lmvshc98ijpnqiana2.png" alt=" " width="778" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Status symbols make it instantly clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Green checkmark&lt;/strong&gt; - Running smoothly&lt;/li&gt;
&lt;li&gt;❌ &lt;strong&gt;Red X&lt;/strong&gt; - Stopped/crashed&lt;/li&gt;
&lt;li&gt;⚠️ &lt;strong&gt;Yellow warning&lt;/strong&gt; - High resource usage&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔧 Advanced Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Detailed Process Information
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker info mybot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Process Information: mybot
Status: ✓ Running
PID: 123456
Script: /home/user/bots/trading_bot.py
CPU Usage: 2.1%
Memory: 45.2 MB
Started: 2025-08-19 09:30:15
Virtual env: ./venv
Python executable: /home/user/project/venv/bin/python
Log file: /home/user/.pyker/logs/mybot.log
Auto restart: Yes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Smart Log Managemente
&lt;/h3&gt;

&lt;p&gt;py real-time&lt;br&gt;
pyt -ker logs mybot -ow lines last 100 linesot&lt;br&gt;
pyker logs mybot are automatically rotated based on size, preventing disk space issues.&lt;/p&gt;
&lt;h3&gt;
  
  
  Tab Completion
&lt;/h3&gt;

&lt;p&gt;Pyker includes intelligent tab completion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker &amp;lt;TAB&amp;gt;          &lt;span class="c"&gt;# Shows available commands&lt;/span&gt;
pyker stop &amp;lt;TAB&amp;gt;     &lt;span class="c"&gt;# Completes with running process names&lt;/span&gt;
pyker logs bot&amp;lt;TAB&amp;gt;  &lt;span class="c"&gt;# Completes process names&lt;/span&gt;
pyker start app script.py &lt;span class="nt"&gt;--&lt;/span&gt;&amp;lt;TAB&amp;gt;  &lt;span class="c"&gt;# Shows --venv, --auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🛡️ Built for Reliability
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Auto-restart on Failure
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start critical-service app.py &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your script crashes, Pyker automatically restarts it and logs the incident.&lt;/p&gt;

&lt;h3&gt;
  
  
  Safe Uninstallation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker uninstall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pyker includes a built-in uninstall command that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shows exactly what will be removed&lt;/li&gt;
&lt;li&gt;Stops all running processes with confirmation&lt;/li&gt;
&lt;li&gt;Optionally preserves logs and configuration&lt;/li&gt;
&lt;li&gt;Can be cancelled at any point&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🎯 Real-world Use Cases
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Web Developers:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start api app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
pyker start worker celery_worker.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Data Scientists:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start jupyter jupyter_server.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./ml-env
pyker start training train_model.py &lt;span class="nt"&gt;--venv&lt;/span&gt; /opt/conda/envs/pytorch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DevOps/Automation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start monitor system_monitor.py &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
pyker start backup backup_script.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./tools-env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Discord/Telegram Bots:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pyker start discord-bot bot.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./bot-env &lt;span class="nt"&gt;--auto-restart&lt;/span&gt;
pyker logs discord-bot &lt;span class="nt"&gt;-f&lt;/span&gt;  &lt;span class="c"&gt;# Monitor bot activity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔄 Migration from PM2
&lt;/h2&gt;

&lt;p&gt;Coming from PM2? The transition is smooth:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;PM2&lt;/th&gt;
&lt;th&gt;Pyker&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pm2 start app.js&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pyker start app app.py&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Similar syntax&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pm2 list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pyker list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Enhanced table view&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pm2 logs app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pyker logs app -f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Follow logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pm2 restart app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pyker restart app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Preserves venv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pm2 delete app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;pyker delete app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Clean removal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  🚀 Why Choose Pyker?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Python-First Design&lt;/strong&gt; - Built specifically for Python workflows&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modern UX&lt;/strong&gt; - Beautiful, adaptive interface that fits any terminal&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero Configuration&lt;/strong&gt; - Works out of the box with sensible defaults&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Virtual Environment Native&lt;/strong&gt; - First-class venv support&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight&lt;/strong&gt; - Single Python file, minimal dependencies&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User-Space Installation&lt;/strong&gt; - No root access required&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-Platform&lt;/strong&gt; - Same experience on Linux, macOS, Windows&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🔮 What's Next?
&lt;/h2&gt;

&lt;p&gt;Pyker is actively developed with upcoming features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web dashboard for remote monitoring&lt;/li&gt;
&lt;li&gt;Integration with systemd for true service management&lt;/li&gt;
&lt;li&gt;Docker container support&lt;/li&gt;
&lt;li&gt;Process health checks and notifications&lt;/li&gt;
&lt;li&gt;Configuration file support for complex setups&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📥 Get Started Today
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Pyker&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/pyker/main/install.sh | bash

&lt;span class="c"&gt;# Start your first process&lt;/span&gt;
pyker start myapp app.py &lt;span class="nt"&gt;--venv&lt;/span&gt; ./venv

&lt;span class="c"&gt;# Monitor it&lt;/span&gt;
pyker list
pyker logs myapp &lt;span class="nt"&gt;-f&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🤝 Contributing
&lt;/h2&gt;

&lt;p&gt;Pyker is open source and welcomes contributions! Whether it's bug reports, feature requests, or code contributions, check out our &lt;a href="https://github.com/mrvi0/pyker" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Made with ❤️ for Python developers who want simple, reliable process management.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you tried Pyker? Share your experience in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>devops</category>
      <category>cli</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>ConfWatch v3.0.0: Configuration File Monitoring with Secure Authentication</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Tue, 22 Jul 2025 21:54:51 +0000</pubDate>
      <link>https://dev.to/mrvi0/confwatch-v300-configuration-file-monitoring-with-secure-authentication-4a51</link>
      <guid>https://dev.to/mrvi0/confwatch-v300-configuration-file-monitoring-with-secure-authentication-4a51</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmny2yg1roaj3ptn5oriu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmny2yg1roaj3ptn5oriu.png" alt="ConfWatch Logo" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is ConfWatch?
&lt;/h2&gt;

&lt;p&gt;ConfWatch is a Python-based tool for monitoring and versioning configuration files. It provides a powerful CLI and a terminal-style web interface for managing configuration file changes, history, and diffs.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Key Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monitor any configuration files&lt;/strong&gt; (dotfiles, .env, /etc/*, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic versioning&lt;/strong&gt; (Git-based, per-file, with unique safe names)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;History for every file&lt;/strong&gt; (see all changes with date and comment)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Diff between any two snapshots&lt;/strong&gt; (choose any two versions to compare)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terminal-style web interface&lt;/strong&gt; (for easy browsing and diff viewing)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secure authentication&lt;/strong&gt; (unique password per installation)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🛠️ Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Quick Install (Recommended)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mrvi0/conf-watch/main/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The installer automatically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installs to &lt;code&gt;~/.confwatch/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Adds &lt;code&gt;confwatch&lt;/code&gt; to your PATH&lt;/li&gt;
&lt;li&gt;Creates virtual environment, config, repo, web interface&lt;/li&gt;
&lt;li&gt;Generates a unique password for the web interface&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Development Install
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/mrvi0/conf-watch.git
&lt;span class="nb"&gt;cd &lt;/span&gt;conf-watch
./install-dev.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📝 Configuration
&lt;/h2&gt;

&lt;p&gt;Edit &lt;code&gt;~/.confwatch/config/config.yml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# List of files to monitor&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;~/.bashrc&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;~/.zshrc&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;~/.ssh/config&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;~/.env&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/etc/nginx/nginx.conf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  💻 CLI Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List monitored files&lt;/span&gt;
confwatch list

&lt;span class="c"&gt;# Create snapshot with comment&lt;/span&gt;
confwatch snapshot ~/.bashrc &lt;span class="nt"&gt;--comment&lt;/span&gt; &lt;span class="s2"&gt;"After installing nvm"&lt;/span&gt;

&lt;span class="c"&gt;# Show differences&lt;/span&gt;
confwatch diff ~/.env

&lt;span class="c"&gt;# Show file history&lt;/span&gt;
confwatch &lt;span class="nb"&gt;history&lt;/span&gt; /etc/nginx/nginx.conf

&lt;span class="c"&gt;# Tag current version&lt;/span&gt;
confwatch tag ~/.bashrc &lt;span class="s2"&gt;"after-nvm-install"&lt;/span&gt;

&lt;span class="c"&gt;# Rollback to specific version&lt;/span&gt;
confwatch rollback ~/.bashrc abc1234

&lt;span class="c"&gt;# Start web interface&lt;/span&gt;
confwatch web &lt;span class="nt"&gt;--port&lt;/span&gt; 9000

&lt;span class="c"&gt;# Reset web interface password&lt;/span&gt;
confwatch reset-password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌐 Web Interface
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;confwatch web&lt;/code&gt; and open &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure authentication with unique password&lt;/li&gt;
&lt;li&gt;Browse all monitored files&lt;/li&gt;
&lt;li&gt;View change history with ability to compare any versions&lt;/li&gt;
&lt;li&gt;Animated CLI demo&lt;/li&gt;
&lt;li&gt;Terminal-style interface&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔐 Security
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;New authentication system in v3.0.0:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each installation gets a unique password&lt;/li&gt;
&lt;li&gt;No default passwords&lt;/li&gt;
&lt;li&gt;Easy reset via CLI&lt;/li&gt;
&lt;li&gt;SHA-256 password hashing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📊 Project Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/.confwatch/
├── venv/                # Python virtual environment
├── config/config.yml    # List of monitored files
├── repo/                # Git repo with all file versions
├── web/                 # Web UI static files
├── confwatch            # Launcher script
└── confwatch-module/    # All Python code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🔍 Usage Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Monitoring dotfiles
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;confwatch snapshot ~/.bashrc ~/.zshrc &lt;span class="nt"&gt;--comment&lt;/span&gt; &lt;span class="s2"&gt;"Shell configuration update"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Tracking service configurations
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;confwatch snapshot /etc/nginx/nginx.conf &lt;span class="nt"&gt;--comment&lt;/span&gt; &lt;span class="s2"&gt;"Nginx configuration changes"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Comparing versions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;confwatch diff ~/.env
confwatch &lt;span class="nb"&gt;history&lt;/span&gt; ~/.ssh/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🆕 What's New in v3.0.0
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Secure authentication&lt;/strong&gt; - unique password for each installation&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Improved web interface&lt;/strong&gt; - logout button and dynamic version&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Password reset command&lt;/strong&gt; - &lt;code&gt;confwatch reset-password&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Updated documentation&lt;/strong&gt; - detailed README in English and Russian&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🤝 Contributing
&lt;/h2&gt;

&lt;p&gt;The project is open for contributions! If you have ideas or found bugs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an issue on GitHub&lt;/li&gt;
&lt;li&gt;Fork the repository&lt;/li&gt;
&lt;li&gt;Create a pull request&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  📚 Documentation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mrvi0/conf-watch" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mrvi0/conf-watch/blob/main/README.md" rel="noopener noreferrer"&gt;English README&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/mrvi0/conf-watch/blob/main/docs/ru/README.md" rel="noopener noreferrer"&gt;Russian README&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;ConfWatch is an excellent tool for system administrators, developers, and anyone who wants to control changes in configuration files. Simple installation, powerful functionality, and beautiful web interface make it an indispensable assistant in daily work.&lt;/p&gt;

&lt;p&gt;Try ConfWatch and share your impressions in the comments!&lt;/p&gt;

</description>
      <category>devops</category>
      <category>opensource</category>
      <category>bash</category>
      <category>linux</category>
    </item>
    <item>
      <title>SSH Login Alert Bot</title>
      <dc:creator>Mr Vi</dc:creator>
      <pubDate>Fri, 09 Dec 2022 07:01:21 +0000</pubDate>
      <link>https://dev.to/mrvi0/ssh-login-alert-bot-9h6</link>
      <guid>https://dev.to/mrvi0/ssh-login-alert-bot-9h6</guid>
      <description>&lt;h3&gt;
  
  
  How to use
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Create telegram bot
&lt;/h4&gt;

&lt;p&gt;To send a message to Telegram group or channel, you should first create your own bot. Just open Telegram, find &lt;a href="https://t.me/botfather" rel="noopener noreferrer"&gt;@BotFather&lt;/a&gt; and type &lt;code&gt;/start&lt;/code&gt;. Then follow instructions to create bot and get token to access the HTTP API.&lt;/p&gt;

&lt;h4&gt;
  
  
  Create Channel
&lt;/h4&gt;

&lt;p&gt;Create a new Channel in Telegram and add your bot as a member. So your bot could send messages to the Channel.&lt;/p&gt;

&lt;p&gt;In order to get Channel Id, first, post any message to the Channel. Then use this link template to get Channel Id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;https://api.telegram.org/bot&amp;lt;YourBOTToken&amp;gt;/getUpdates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a response example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"ok"&lt;/span&gt;:true,
  &lt;span class="s2"&gt;"result"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"update_id"&lt;/span&gt;:123,
      &lt;span class="s2"&gt;"channel_post"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"message_id"&lt;/span&gt;:48,
        &lt;span class="s2"&gt;"chat"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
          &lt;span class="s2"&gt;"id"&lt;/span&gt;:-123123123, // this is your channel &lt;span class="nb"&gt;id&lt;/span&gt;
          &lt;span class="s2"&gt;"title"&lt;/span&gt;:&lt;span class="s2"&gt;"Notifications"&lt;/span&gt;,
          &lt;span class="s2"&gt;"type"&lt;/span&gt;:&lt;span class="s2"&gt;"channel"&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;,
        &lt;span class="s2"&gt;"date"&lt;/span&gt;:1574485277,
        &lt;span class="s2"&gt;"text"&lt;/span&gt;:&lt;span class="s2"&gt;"test"&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Clone the repo
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/vi-dev0/login-alert-bot.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add token and chat ID
&lt;/h4&gt;

&lt;p&gt;Add bot token and chat ID in &lt;code&gt;telegram-send.sh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

GROUP_ID=&amp;lt;group_id&amp;gt;
BOT_TOKEN=&amp;lt;bot_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add permissions
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x telegram-send.sh
chmod +x login-notify.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Move to scripts folder
&lt;/h4&gt;

&lt;p&gt;In order to use this script from everywhere and type telegram-send instead &lt;code&gt;./telegram-send.sh&lt;/code&gt; add it to &lt;code&gt;/usr/bin/&lt;/code&gt; folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mv telegram-send.sh /usr/bin/telegram-send
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Owner of all files in /usr/bin is root user. So let's do the same with our script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown root:root /usr/bin/telegram-send
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can test it:&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;telegram-send "Test message"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Move &lt;code&gt;login-notify.sh&lt;/code&gt; script to &lt;code&gt;/etc/profile.d/&lt;/code&gt; folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mv login-notify.sh /etc/profile.d/login-notify.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Now re-login to your web server and check it works.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Contact
&lt;/h2&gt;

&lt;p&gt;Mr Vi - &lt;a href="https://twitter.com/vi_dev0" rel="noopener noreferrer"&gt;@vi_dev0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Project Link: &lt;a href="https://github.com/vi-dev0/login-alert-bot" rel="noopener noreferrer"&gt;Login Alert Bot&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>telegram</category>
    </item>
  </channel>
</rss>
