Comments (7)
I tried adding this to my model.py
:
from rest_framework import routers, serializers, viewsets, mixins
from cabot import create_viewset, status_check_fields
router = routers.DefaultRouter()
router.register(r'status_go_checks', create_viewset(
arg_model=StatusGoStatusCheck,
arg_fields=status_check_fields + (
'node_type',
'enode',
),
))
But worker fails to start with:
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 8, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 203, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 231, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 344, in halt
self.stop()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 393, in stop
time.sleep(0.1)
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 244, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 524, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
from cabot.
Worker shows in logs this:
Traceback (most recent call last):
File "/usr/local/bin/celery", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/celery/__main__.py", line 16, in main
_main()
File "/usr/local/lib/python2.7/site-packages/celery/bin/celery.py", line 322, in main
cmd.execute_from_commandline(argv)
File "/usr/local/lib/python2.7/site-packages/celery/bin/celery.py", line 496, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
File "/usr/local/lib/python2.7/site-packages/celery/bin/base.py", line 275, in execute_from_commandline
return self.handle_argv(self.prog_name, argv[1:])
File "/usr/local/lib/python2.7/site-packages/celery/bin/celery.py", line 488, in handle_argv
return self.execute(command, argv)
File "/usr/local/lib/python2.7/site-packages/celery/bin/celery.py", line 420, in execute
).run_from_argv(self.prog_name, argv[1:], command=argv[0])
File "/usr/local/lib/python2.7/site-packages/celery/bin/worker.py", line 223, in run_from_argv
return self(*args, **options)
File "/usr/local/lib/python2.7/site-packages/celery/bin/base.py", line 238, in __call__
ret = self.run(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/celery/bin/worker.py", line 257, in run
**kwargs)
File "/usr/local/lib/python2.7/site-packages/celery/worker/worker.py", line 96, in __init__
self.app.loader.init_worker()
File "/usr/local/lib/python2.7/site-packages/celery/loaders/base.py", line 114, in init_worker
self.import_default_modules()
File "/usr/local/lib/python2.7/site-packages/celery/loaders/base.py", line 108, in import_default_modules
raise response
ImportError: cannot import name create_viewset
from cabot.
I think I figured it out, based on looking at this method:
Lines 174 to 187 in eb0b354
Specifically this part:
urlpatterns += [
url(r'^plugins/%s/' % plugin, include('%s.urls' % plugin))
]
Which means that the contents of urls.py
file in a plugin are loaded into urlpatterns
under plugins/
.
from cabot.
I managed to get a route working by adding this:
from django.conf.urls import include, url
from rest_framework.routers import DefaultRouter
from cabot.rest_urls import create_viewset, status_check_fields
from .models import StatusGoStatusCheck
api_router = DefaultRouter()
api_router.register(r'status_go_checks', create_viewset(
arg_model=StatusGoStatusCheck,
arg_fields=status_check_fields + (
'node_type',
'enode',
),
))
urlpatterns = [
url(r'^api/', include(api_router.urls)),
# other routes omitted
]
And by doing this I managed to find my route using the cabot shell
command:
>>> from cabot.urls import urlpatterns
>>> urlpatterns[-2]
<RegexURLResolver <module 'cabot_check_status_go.urls' from '/usr/local/lib/python2.7/site-packages/cabot_check_status_go/urls.pyc'> (None:None) ^plugins/cabot_check_status_go/>
>>> urlpatterns[-2].url_patterns
[<RegexURLResolver <RegexURLPattern list> (None:None) ^api/>]
Which showed me that I can now access the API under: /plugins/cabot_check_status_go/api/status_go_checks/
from cabot.
I'm not sure if there is an easy way to put this directly under /api/
at the root, but putting it under /plugins/cabot_check_status_go/
is good enough for me.
from cabot.
@jakubgs I'm not sure you meant to post this on this repo?
from cabot.
Heh, true, that's what happens when you have too many tabs and working on too many issues at the same time.
from cabot.
Related Issues (20)
- worker not subscribing to tasks from docker-compose / Checks not running
- Feature request: TLS 1.3 support
- Move documentation to README/Github HOT 2
- Planning migrate to Django 2.2? HOT 3
- Email alerts sent once not multiple times HOT 1
- There are no global settings yet HOT 2
- Jenkins check shows passing even though the status is failed HOT 5
- GitHub OAuth fails with redirect_uri_mismatch HOT 5
- How to create first user at setup time? HOT 15
- Cabot using deprecated access_token GitHub query parameter HOT 4
- The is_public setting for services appears to be ignored HOT 5
- Not receiving phone call when ICMP is down HOT 8
- Decrease frequency check to trigger alert! HOT 1
- docker-compose fails on Raspberry Pi 4 32bit
- Service 'beat' failed to build : The command '/bin/sh -c pip install --no-cache-dir -r requirements.txt' returned a non-zero code: 1 HOT 3
- Docker Images build fails HOT 1
- Pushes from alertmanager HOT 1
- Potential usage of cabot for WordPress Maintenance service?
- Twilio TLS certificate is not accepted by the Cabot docker image, so SMS and phone call notifications do not work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cabot.