Git Product home page Git Product logo

python-service-example's Introduction

python-service-example

A simple example for creating a linux systemd service which is a python script

Features:

  • Automatic logging with systemd
  • Runs automatically at boot

How to adapt:

  1. Change the service name (service_name="your_service") in all .sh files to an expressive service name
  2. Adapt the description in my_service.service
  3. Adapt the python executable and script path in my_service.service (ExecStart=executable_path -u script_path)
  4. (Optional) adapt the user which should run your python script in my_service.service
  5. change the name of the my_service.service to the service name set in the sh files (e.g. your_service.service)

How to get log/status:

Run in bash: service your_service status

Optional Extensions:

  • Copy the python script file to a constant location (e.g. /usr/local/bin/your_service/) in install.sh and remove that directory in uninstall.sh
  • Add a config file for your service to a constant location (e.g. /etc/your_service/)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.