Skip to main content

service-bootstrap

Helper for starting up a service in python

Function start_service()

Usage:

from bootstrap.bootstrap import start_service

config, logger, timezone = start_service()

Configuration

start_service() will look for a config YAML file and load it into a dict, using the following algorithm:

  • if the env variable CONFIG is defined, it will be used to determine the location of the config file
  • otherwise a file ./config.yaml is expected to be present

The file will be parsed and returned as a first returned variable

Logging

start_service() will configure the logger will in the following way:

  1. if ./logging.yaml exists, it will be loaded into a dict and used to configure logging (using dictConfig)
  2. otherwise the default logging format will be applied, which is defined as writing logs on INFO level to stdout

Additionally, start_service() will look for ./loglevels.yaml file with the following structure:

'apscheduler.scheduler': 'ERROR',
'apscheduler.executors.default': 'WARN'

and use this file to configure per-logger log levels. Note that the settings two mentioned above ('apscheduler.scheduler': 'ERROR' and 'apscheduler.executors.default': 'WARN') will be used as a default.

Finally, start_service() will create a logger called main, log two messages

logger.info("Starting application!")
logger.info("Your timezone is %s" % timezone)

and return this logger as a second returned variable

Timezone

The third returned variable will contain the local timezone as a string (f.ex Europe/Warsaw), detected using the following algorithm:

  • if the env variable TIMEZONE is defined, it will be used
  • otherwise timezone will be autodetected using tzlocal

Note on YAML loading

All yaml files are loaded using load_yaml() and may contain env variables!

Function load_yaml()

Usage:

from bootstrap.utils import load_yaml

content = load_yaml("file.yaml")

It will load the content of file.yaml into a dict resolving ENV variables

Metadata

Release files for service-bootstrap 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for service-bootstrap 0.0.5
File Size Uploaded Provenance
service-bootstrap-0.0.5.tar.gz 4.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for service-bootstrap 0.0.5
File Interpreter ABI Platform
service_bootstrap-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 9.8 kB

Release files / service-bootstrap-0.0.5.tar.gz

Download URL service-bootstrap-0.0.5.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb8c2d69ddb855ce6b0bc6f176df73437e4bb5665e35f32cebb47a240ee04566
BLAKE2b-256 checksum
How to use checksums
955e1533ebfb7ee0432fdcd02a8ab03d84f2e2c59072de642317f61e10977247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / service_bootstrap-0.0.5-py3-none-any.whl

Download URL service_bootstrap-0.0.5-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
605055de07d20091afe5d4fe2775705d9844cdc77a6beb84a1852cf2da0e9026
BLAKE2b-256 checksum
How to use checksums
510e730e95d7cf41be81974a096094e1f8eb73b3e062bcbcce43a9cdbd328993
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for service-bootstrap 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page