Giter VIP home page Giter VIP logo

server-reloader's Introduction

Server Reloader

It is common task in all web frameworks — to provide an easy way to reload development server on code changes. Most of these frameworks are carrying a reloader's code with themselves. And there isn't any python module, simple enough to use in a small project.

Some times ago, I started to write a chat bot called TheBot and begun to look for a separate server reloader's implementation. And found nothing suitable.

Then, I extracted autoreloader from the Django's codebase and put it into a separate module, which README you are reading now. Code was partly modified, now it allows not only to watch on file changes but also to reload upon a some event.

Reload on some event is a quite useful feature for TheBot, because now he can update himself on a push to the GitHub. A pseudocode for this procedure will look like:

def on_push_to_the_github_master_branch():
    make_git_pull()
    run_pip_install()
    trigger_code_reload()

And I don't need an external watcher to run bot, because now he uses server-reloader.

Example usage

Here is a simple example, how to use a reloader.

def run_server():
    """Some function, which creates and runs your server."""
    pass

def main():
    server_reloader.main(
        run_server,
        before_reload=lambda: print('Reloading code…')
    )

if __name__ == '__main__':
    main()

If you want to trigger code reloading on some custom event, then just do:

from server_reloader import trigger_reload
trigger_reload()

Credentials

Many thanks to original authors of the autoreloader, I took as the basis.

server-reloader's People

Contributors

svetlyak40wt avatar douglasdollars avatar

Watchers

Sriram Velamur avatar James Cloos avatar

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.