autostart python classes
Project description
startme
startme is systemd/cron alternative for python virtualenv
Problem and solution
Sometimes python application is complex and modular. For example, you may have:
- wsgi web application
- telegram bot
- some database maintenance
- send marketing emails
- ... and more and more
Some of these modules are optional. How to install it (say, telegram bot)? You may install it with pip, but then you need to activate it - edit systemd .service file and install it. Or, for cron jobs, you need to manually add cron job. This makes module installation more complex, long and vulnerable to mistakes.
Startme looks for subclasses of StartMe class and executes it.
Usage
# create virtualenv
pipenv shell
# install startme
pipenv install startme
# Now lets run it. Not very impressive.
(x) xenon@braconnier:/tmp/x$ startme
startme started
(x) xenon@braconnier:/tmp/x$
# Now install example plugin
pipenv install startme-examples
# run again...
(x) xenon@braconnier:/tmp/x$ startme
StartMeExampleBoot started
startme started
00:20:25 Ticker tick 10
00:20:35 Ticker tick 10
00:20:45 Ticker tick 10
00:20:55 Ticker tick 10
00:21:05 Ticker tick 10
00:21:15 Ticker1min tick 60
00:21:15 Ticker tick 10
00:21:25 Ticker tick 10
startme-examples has three very simple classes, inherited from StartMe
. StartMeExampleBoot
- wants to be executed once on start. Ticker
wants to be executed every 10 seconds and Ticker1min
wants to be executed every 1 minute.
Look startme-examples sources as documentation, it's very small. For example, StartMeExampleBoot
is just one class with one method with just one line of code.
from startme import StartMe
class StartMeExampleBoot(StartMe):
def on_start(self):
print(self.__class__.__name__, "started")
All StartMe
subclasses are automatically detected, loaded and executed. No need for systemd or cron inside virtualenv.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file startme-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: startme-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6a3ecf5036fba2300ae101f022fc72f9ea5e9e973d19ac85b96b215b7eacd71 |
|
MD5 | b253c53f485151b677d30cbd9aeca873 |
|
BLAKE2b-256 | e9512ee5bca6d3af1bae9bca6758612557dcf03b44674353cf34ce01d0415fc3 |