forked from YoLoveLife/DevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42971da
commit b007f70
Showing
13 changed files
with
275 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from __future__ import absolute_import,unicode_literals | ||
from .celery import app as celery_app | ||
__all__ = ['celery_app'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,96 @@ | |
# Author Yo | ||
# Email [email protected] | ||
|
||
from __future__ import absolute_import,unicode_literals | ||
# from __future__ import absolute_import,unicode_literals | ||
# import os | ||
# from celery import Celery,platforms | ||
# from execute.service import base as BaseTask | ||
# os.environ.setdefault('DJANGO_SETTINGS_MODULE','deveops.settings') | ||
# platforms.C_FORCE_ROOT = True | ||
# | ||
# app = Celery('deveops') | ||
# app.config_from_object('django.conf:settings') | ||
# from django.conf import settings | ||
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) | ||
|
||
# from celery.schedules import crontab | ||
# from celery.task import periodic_task | ||
|
||
# @periodic_task( | ||
# run_every=(crontab(minute='*',hour='*')), | ||
# name="PingOnlineTask", | ||
# ignore_result=True | ||
# ) | ||
# def PingOnlineTask(): | ||
# # BaseTask.PingOnlineService() | ||
# # from manager.models import Host | ||
# # import time | ||
# # host = Host.objects.all()[0] | ||
# # host.info = str(time.time()) | ||
# # host.save() | ||
# from manager.models import Host | ||
# from execute.ansible.runner import YoRunner | ||
# from execute.callback import ResultCallback | ||
# from operation.models import PlayBook | ||
# from django.conf import settings | ||
# | ||
# hosts = Host.objects.all() | ||
# import time | ||
# for host in hosts: | ||
# host.info = str(time.time()) | ||
# host.save() | ||
# runner = YoRunner(hosts=hosts, extra_vars={}) | ||
# runner.set_callback(ResultCallback()) | ||
# playbook = PlayBook.objects.filter(id=settings.PING_PLAYBOOK_TASK_ID)[0] | ||
# ret = runner.run(playbook.tasks.all()) | ||
|
||
|
||
from __future__ import absolute_import, unicode_literals | ||
import os | ||
from celery import Celery,platforms | ||
from execute.service import base as BaseTask | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE','deveops.settings') | ||
platforms.C_FORCE_ROOT = True | ||
app = Celery('deveops') | ||
from celery import Celery | ||
|
||
# set the default Django settings module for the 'celery' program. | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') | ||
|
||
app = Celery('proj') | ||
|
||
# Using a string here means the worker doesn't have to serialize | ||
# the configuration object to child processes. | ||
# - namespace='CELERY' means all celery-related configuration keys | ||
# should have a `CELERY_` prefix. | ||
app.config_from_object('django.conf:settings') | ||
from django.conf import settings | ||
# Load task modules from all registered Django app configs. | ||
from django.apps import apps | ||
# app.autodiscover_tasks(lambda: [n.name for n in apps.get_app_configs()]) | ||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) | ||
|
||
from celery.schedules import crontab | ||
from celery.task import periodic_task | ||
|
||
from celery.schedules import crontab | ||
@periodic_task( | ||
run_every=(crontab(minute='*',hour='*')), | ||
name="PingOnlineTask", | ||
run_every=(crontab(minute='*')), | ||
name="execute.tasks.PingOnlineTask", | ||
ignore_result=True | ||
) | ||
def PingOnlineTask(): | ||
BaseTask.PingOnlineService() | ||
from manager.models import Host | ||
import time | ||
host = Host.objects.all()[0] | ||
host.info = str(time.time()) | ||
host.save() | ||
|
||
# @app.task(bind=True) | ||
# def debug_task(self): | ||
# print('Request: {0!r}'.format(self.request)) | ||
from celery.schedules import crontab | ||
# | ||
# app.conf.update( | ||
# CELERYBEAT_SCHEDULE = { | ||
# # Executes every Monday morning at 7:30 A.M | ||
# 'add-every-monday-morning': { | ||
# 'task': 'execute.tasks.PingOnlineTask', | ||
# 'schedule': crontab(hour=7, minute=30, day_of_week=1), | ||
# 'args': (16, 16), | ||
# }, | ||
# } | ||
# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-15 | ||
# Author Yo | ||
# Email [email protected] | ||
|
||
def PingOnlineTask(): | ||
# BaseTask.PingOnlineService() | ||
from manager.models import Host | ||
import time | ||
host = Host.objects.all()[0] | ||
host.info = str(time.time()) | ||
host.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from __future__ import absolute_import,unicode_literals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-14 | ||
# Author Yo | ||
# Email [email protected] | ||
# from __future__ import absolute_import | ||
|
||
# from celery.schedules import crontab | ||
# from celery.task import periodic_task | ||
# from celery.utils.log import get_task_logger | ||
# from execute.utils import scrapers | ||
# import datetime | ||
# logger = get_task_logger(__name__) | ||
# | ||
# | ||
# @periodic_task(run_every=(crontab(minute="*"))) | ||
# def scraper_example(): | ||
# logger.info("Start task") | ||
# now = datetime.now() | ||
# result = scrapers.scraper_example(now.day, now.minute) | ||
# logger.info("Task finished: result = %i" % result) | ||
|
||
# from deveops import celery_app | ||
# | ||
# @celery_app.task | ||
# def ddr(): | ||
# print('start send email to %s') | ||
# import time | ||
# time.sleep(5) #休息5秒 | ||
# print('success') | ||
# return True | ||
# | ||
# from celery.schedules import crontab | ||
# from celery.task import periodic_task | ||
# @periodic_task(run_every=crontab(minute='*')) | ||
# def some_task(): | ||
# print('periodic task test!!!!!') | ||
# import time | ||
# time.sleep(5) | ||
# print('success') | ||
# return True | ||
|
||
# Create your tasks here | ||
from __future__ import absolute_import, unicode_literals | ||
from celery.task import task | ||
|
||
@task(name='PingOnlineTask') | ||
def PingOnlineTask(): | ||
from manager.models import Host | ||
import time | ||
host = Host.objects.all()[0] | ||
host.info = str(time.time()) | ||
host.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-14 | ||
# Author Yo | ||
# Email [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-14 | ||
# Author Yo | ||
# Email [email protected] | ||
def scraper_example(a, b): | ||
return a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
;[loggers] | ||
;keys=root,log02 | ||
; | ||
;[handlers] | ||
;keys=hand01,hand02 | ||
; | ||
;[formatters] | ||
;keys=form01,form02 | ||
; | ||
;[logger_parser] | ||
;level=DEBUG | ||
;handlers=hand01 | ||
;propagate=1 | ||
;qualname=compiler.parser | ||
; | ||
;[logger_root] | ||
;level=NOTSET | ||
;handlers=hand01 | ||
; | ||
;[logger_log02] | ||
;level=DEBUG | ||
;handlers=hand02 | ||
;propagate=1 | ||
;qualname=compiler.parser | ||
; | ||
;[handler_hand01] | ||
;class=StreamHandler | ||
;level=NOTSET | ||
;formatter=form01 | ||
;args=(sys.stdout,) | ||
; | ||
;[handler_hand02] | ||
;class=FileHandler | ||
;level=DEBUG | ||
;formatter=form02 | ||
;args=('logs/myapp.log', 'w') | ||
; | ||
;[formatter_form01] | ||
;format=F1 %(asctime)s %(levelname)s %(message)s | ||
;datefmt= | ||
;class=logging.Formatter | ||
; | ||
;[formatter_form02] | ||
;format=%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s | ||
;datefmt=%a, %d %b %Y %H:%M:%S | ||
;class=logging.Formatter | ||
|
||
[loggers] | ||
keys=root,all,api | ||
|
||
[handlers] | ||
keys=fileHandler | ||
|
||
[formatters] | ||
keys=format | ||
|
||
[logger_root] | ||
level=INFO | ||
handlers=fileHandler | ||
|
||
[logger_all] | ||
level=INFO | ||
handlers=fileHandler | ||
qualname=deveops | ||
|
||
[logger_api] | ||
level=INFO | ||
handlers=fileHandler | ||
qualname=deveops.api | ||
|
||
[logger_api] | ||
level=INFO | ||
handlers=fileHandler | ||
|
||
[handler_fileHandler] | ||
class=FileHandler | ||
level=INFO | ||
formatter=format | ||
args=('logs/deveops.log', 'w') | ||
|
||
[formatter_format] | ||
format=%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] [%(module)s:%(funcName)s] [%(levelname)s]- %(message)s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from __future__ import absolute_import,unicode_literals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-16 | ||
# Author Yo | ||
# Email [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding:utf-8 -*- | ||
# !/usr/bin/env python | ||
# Time 17-11-16 | ||
# Author Yo | ||
# Email [email protected] | ||
|
||
def decorator_manager(asset_id,api_name,):#host group storage | ||
def wrapper(func): | ||
def inner_wrapper(): | ||
print(name) | ||
func() | ||
return inner_wrapper | ||
return wrapper | ||
|
||
@decorator_host(name='ddr') | ||
def ddr(): | ||
print('function') | ||
|
||
if __name__ == '__main__': | ||
ddr() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Django==1.11.3 | ||
logging==0.4.9.6 | ||
Jinja2==2.9.6 | ||
MySQL-python==1.2.5 | ||
Pillow==4.2.1 | ||
|