Code Monkey home page Code Monkey logo

beatserver's People

Contributors

blackrobot avatar ecreality avatar rajasimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beatserver's Issues

Support for all ASGI frameworks

One of the cool thing about ASGI is we can hook with asyncio loop easily and that allows us to implement background task not just to channels but any ASGI framework. I'm going to invest some time around this year to change the code to support for all the asgi applications.

Allow for several types/messages per channel

Hello, first i'd like to thank you for this module.
I would like to have several periodic tasks. I've thought about grouping them in a specific channel? so the would be all together. But as i see in the code, it's about a single task per channel name.
In order to support different message types in one channel, there should be 2 cycles here

for key, value in self.beat_config.items():

Outer one should cycle through channel name/config(key-value), and inner one should cycle through message types. Or there would be one cycle, but config shoud be a list instead of dictionary(maybe a list of tuples?), so that there could be several items with the same channel name and maybe the same message type.

examples does not work

image
image

When I clone this project and run it as follow, but it has problem as picture, please help me to run it.

won't work with more than 1 beat tasks

hey, I need to run 2 different task with beatserver, I use django2.x and channels2.x,
in consumers.py I write a class BeatServer as:

class BeatServer(SyncConsumer):
    def task_one(self, message):
        print("task 1 #############")
        data = {"task_one": "ok"}
        room_group_name_one = "room_one"
        async_to_sync(self.channel_layer.group_send)(room_group_name_one, {
            "type": "chat.message",
            "message": data
        })

    def task_two(self, message):
        print("task 2 #############")
        data = {"task_two": "ok"}
        room_group_name_two = "room_two"
        async_to_sync(self.channel_layer.group_send)(room_group_name_two, {
            "type": "chat.message",
            "message": data
        })

and beatconfig.py as below

from datetime import timedelta

BEAT_SCHEDULE = {
    'task-one': {
        'type': 'task_one',
        'message': {'message': 'send successed'},
        'schedule': timedelta(seconds=4)
    },
    'task-two': {
        'type': 'task_two',
        'message': {'message': 'send successed'},
        'schedule': timedelta(seconds=4)
    },
}

then run beatserver as python3 manage.py beatserver
I can see task 1 #############, and things were going well on client
but task two seens not work, i cannot see any tag, and clients can not receive any messages.
and there are no errors raise.

can it be done if more than one tasks with beatserver?

Instructions for using in production

Hello,
As i understand, spinning up the beatserver is done separately from spinning up my django server.
So how would i go about using this in production, if my stack consists of Gunicorn + Daphne (channels and db already configured with redis channel layer )

So for simplicity, lets say that my current deployment script runs this command
sudo systemctl restart gunicorn.service && sudo systemctl restart nginx && sudo systemctl restart daphne.service

and in my gunicorn config my ExecStart is
gunicorn my_app.wsgi --bind 0.0.0.0:8000 --log-level error --log-file=- --workers 5 --preload

daphne ExecStart
ExecStart=/home/ubuntu/env/bin/daphne --bind 0.0.0.0 --port <my_port> --verbosity 2 my_app.asgi:application

how can i also spin up beatserver to play nice with the others ?

Static files are not provided

Hey, thanks for the project! I cloned the repo and tried to run the example, but there are no static files, namely, there is no websocketbridge.js file

how can I run beatserver

After installed with command pip3 install -U beatserver, OS can not recognize command 'beatserver' on OSX.
BTW, beatserver is a websocket server which can continuely send message to clients browser frontend if I didn't make any misunderstanding?

Examples App

Nice if this project have the examples to play with.

Make the repeated task execute immediate after the server started

Currently the mentioned task in the beatconfig execute after the schedule time and repeat but that's okay but make it option to execute the task immediate. I think the immediate execution of the task should be in default mode and make it options to the current behaviour.

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.