FediFetcher/examples/systemd.md
Tealk b18333cdc4 add systemd guide
Signed-off-by: Tealk <tealk@rollenspiel.monster>
2024-03-15 08:58:22 +01:00

2.1 KiB

  1. Navigate to the directory /opt:

    cd /opt
    
  2. Clone the FediFetcher repository from GitHub:

    git clone https://github.com/nanos/FediFetcher.git
    
  3. Create a Python Virtual Environment named fedifetcher:

    python3 -m venv fedifetcher
    
  4. Change to the FediFetcher directory:

    cd FediFetcher
    
  5. Activate the virtual environment:

    source /opt/fedifetcher/bin/activate
    
  6. Install the required Python packages from the requirements.txt file:

    pip install -r requirements.txt
    
  7. Deactivate the virtual environment:

    deactivate
    
  8. Configure FediFetcher according to the instructions provided at: Configuration Options.

  9. Run FediFetcher for the first time:

    /opt/fedifetcher/bin/python3 find_posts.py -c=artifacts/config.json
    
  10. Create a systemd service file for FediFetcher:

    nano /etc/systemd/system/fedifetcher.service
    

    Paste the following content:

    [Unit]
    Description=FediFetcher Service
    After=network.target
    
    [Service]
    Type=simple
    User=root
    WorkingDirectory=/opt/FediFetcher
    ExecStart=/opt/fedifetcher/bin/python find_posts.py -c=artifacts/config.json
    
    [Install]
    WantedBy=multi-user.target
    
  11. Create a systemd timer file for FediFetcher:

    nano /etc/systemd/system/fedifetcher.timer
    

    Paste the following content:

    [Unit]
    Description=FediFetcher Timer
    
    [Timer]
    OnCalendar=*-*-* *:*:00
    Persistent=true
    
    [Install]
    WantedBy=timers.target
    
  12. Reload the systemd daemon configuration:

    systemctl daemon-reload
    
  13. Start the FediFetcher timer and enable it to start at every system boot:

    systemctl start --now fedifetcher.timer
    

With these steps, FediFetcher should be successfully set up on your system and automatically started to fetch posts regularly.