Scripts for python scripts for (re)start/stop without pain. **UNIX-ONLY!!!**
Go to file
2026-03-07 13:08:49 +03:00
.gitignore Remove pid.txt from repo 2026-03-07 13:08:49 +03:00
example.sh Up 2026-03-07 12:56:09 +03:00
LICENSE Update LICENSE 2026-03-06 17:02:23 +00:00
main.py Up 2026-03-07 12:56:09 +03:00
README.md Update README.md 2026-03-07 10:08:21 +00:00
service.py Up 2026-03-07 12:56:09 +03:00

tg_bots_scripts

Scripts for telegram bot for (re)start/stop without pain.
UNIX-ONLY!!!

Examples

In repository you see examples:

  • main.py - your main file
  • example.sh - optional script for checking exit code (not needed)

service.py is the what you will use for managment of main.py

Usage

  1. Put service.py in yours project.
  2. Set name of main script - main.py
  3. Inject in main.py AT THE BEGINNING:
import os

# Process Identification Number (PID in Unix(-like))
pid = os.getpid()

with open("pid.txt", "w") as f:
    f.write(str(pid))
  1. Use the service.py so:
Usage: python service.py <option>

Options:
    status  - Get status of main script.
    start   - Start main script.
    stop    - Stop main script.
    restart - Restart main script.

Exit codes meaning

  • status
    • 0 - running
    • 1 - stopped
  • start
    • 0 - started
    • 1 - can't start
    • 2 - already running
  • stop
    • 0 - stopped
    • 2 - already stopped
  • restart
    • 0 - restarted
    • 1 - can't start