@@ -1,4 +1,4 | |||||
1 |
version: ' |
|
1 | version: '3' | |
2 |
|
2 | |||
3 | services: |
|
3 | services: | |
4 | web: |
|
4 | web: | |
@@ -6,15 +6,20 services: | |||||
6 | build: . |
|
6 | build: . | |
7 | restart: always |
|
7 | restart: always | |
8 | image: realtime |
|
8 | image: realtime | |
9 | command: python manage.py runserver 0.0.0.0:8000 |
|
9 | # command: python manage.py runserver 0.0.0.0:8000 | |
|
10 | # command: gunicorn realtime.wsgi:application --bind 0.0.0.0:8080 | |||
|
11 | command: daphne -b 0.0.0.0 -p 8080 realtime.asgi:application | |||
10 | env_file: .env |
|
12 | env_file: .env | |
11 | ports: |
|
13 | # ports: | |
12 |
- "80 |
|
14 | # - "8081:8081" | |
|
15 | # expose: | |||
|
16 | # - 8000 | |||
13 | links: |
|
17 | links: | |
14 | - redis |
|
18 | - redis | |
15 | - mongo |
|
19 | - mongo | |
16 | volumes: |
|
20 | volumes: | |
17 | - './:${APP_DIR}' |
|
21 | - './:${APP_DIR}' | |
|
22 | - './static:/static' | |||
18 | depends_on: |
|
23 | depends_on: | |
19 | - redis |
|
24 | - redis | |
20 | - mongo |
|
25 | - mongo | |
@@ -37,9 +42,9 services: | |||||
37 |
|
42 | |||
38 | redis: |
|
43 | redis: | |
39 | container_name: 'realtime_redis' |
|
44 | container_name: 'realtime_redis' | |
40 |
image: 'redis: |
|
45 | image: 'redis:5.0-alpine' | |
41 | volumes: |
|
46 | volumes: | |
42 |
- 'redis |
|
47 | - '/data/dockers/realtime/redis:/data' | |
43 |
|
48 | |||
44 | mongo: |
|
49 | mongo: | |
45 | container_name: 'realtime_mongo' |
|
50 | container_name: 'realtime_mongo' | |
@@ -48,8 +53,30 services: | |||||
48 | ports: |
|
53 | ports: | |
49 | - '127.0.0.1:27017:27017' |
|
54 | - '127.0.0.1:27017:27017' | |
50 | volumes: |
|
55 | volumes: | |
51 |
- 'mongo |
|
56 | - '/data/dockers/realtime/mongo:/data/db' | |
|
57 | ||||
|
58 | #volumes: | |||
|
59 | # redisdata: | |||
|
60 | # mongodata: | |||
|
61 | ||||
|
62 | nginx: | |||
|
63 | image: nginx:1.15-alpine | |||
|
64 | volumes: | |||
|
65 | - ./static:/static | |||
|
66 | - ./nginx:/etc/nginx/conf.d | |||
|
67 | - ./certbot/conf:/etc/letsencrypt | |||
|
68 | - ./certbot/www:/var/www/certbot | |||
|
69 | ports: | |||
|
70 | - "8000:8000" | |||
|
71 | - "443:443" | |||
|
72 | depends_on: | |||
|
73 | - web | |||
|
74 | command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'" | |||
|
75 | ||||
|
76 | certbot: | |||
|
77 | image: certbot/certbot:latest | |||
|
78 | volumes: | |||
|
79 | - ./certbot/conf:/etc/letsencrypt | |||
|
80 | - ./certbot/www:/var/www/certbot | |||
|
81 | entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'" | |||
52 |
|
82 | |||
53 | volumes: |
|
|||
54 | redisdata: |
|
|||
55 | mongodata: No newline at end of file |
|
@@ -90,7 +90,7 class PlotConsumer(WebsocketConsumer): | |||||
90 | 'plot': plot |
|
90 | 'plot': plot | |
91 | }) |
|
91 | }) | |
92 | if meta1: |
|
92 | if meta1: | |
93 | if meta1['metadata']['type'] in ('pcolor',): |
|
93 | if meta1['metadata']['type'] in ('pcolor', 'image'): | |
94 | datas = DB.plot_data.find( |
|
94 | datas = DB.plot_data.find( | |
95 | {'plot': meta1['_id']}, |
|
95 | {'plot': meta1['_id']}, | |
96 | ['time', 'data'], |
|
96 | ['time', 'data'], |
@@ -1,9 +1,9 | |||||
1 |
from django. |
|
1 | from django.urls import re_path | |
2 |
|
2 | |||
3 | from . import consumers |
|
3 | from . import consumers | |
4 |
|
4 | |||
5 | websocket_urlpatterns = [ |
|
5 | websocket_urlpatterns = [ | |
6 |
|
|
6 | re_path(r'^ws/main/$', consumers.MainConsumer.as_asgi()), | |
7 |
|
|
7 | re_path(r'^ws/realtime/(?P<code>[^/]+)/(?P<plot>[^/]+)/$', consumers.PlotConsumer.as_asgi()), | |
8 |
|
|
8 | re_path(r'^ws/database/(?P<code>[^/]+)/(?P<plot>[^/]+)/$', consumers.PlotConsumer.as_asgi()), | |
9 | ] No newline at end of file |
|
9 | ] |
@@ -39,7 +39,7 | |||||
39 | </ul> |
|
39 | </ul> | |
40 | </div> |
|
40 | </div> | |
41 | <iframe class="map d-none d-sm-block" |
|
41 | <iframe class="map d-none d-sm-block" | |
42 | src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d3901.828012758223!2d-76.94633793139629!3d-12.055351713347235!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x7ea774b6fa66a3c6!2sInstituto+Geof%C3%ADsico+del+Per%C3%BA!5e0!3m2!1ses-419!2spe!4v1545658855595" |
|
42 | src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d31226.562310315738!2d-76.89329626296218!3d-11.952312343404692!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x9105c3290814e129%3A0x61f92c3cfc90797b!2sRadio%20Observatorio%20de%20Jicamarca!5e0!3m2!1sen!2spe!4v1613758699300!5m2!1sen!2spe" | |
43 |
|
|
43 | width="100%" height="100%" frameborder="0" allowfullscreen="false">  | |
44 | </iframe> |
|
44 | </iframe> | |
45 | </footer> No newline at end of file |
|
45 | </footer> |
@@ -37,8 +37,9 | |||||
37 | {% endif %} |
|
37 | {% endif %} | |
38 | {% endblock %} |
|
38 | {% endblock %} | |
39 | {% block script %} |
|
39 | {% block script %} | |
40 |
<script> |
|
40 | <script> | |
41 | var socket = new WebSocket('ws://' + window.location.host +'/ws/main/'); |
|
41 | var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws"; | |
|
42 | var socket = new WebSocket(ws_scheme + '://' + window.location.host +'/ws/main/'); | |||
42 | socket.onopen = function open() { |
|
43 | socket.onopen = function open() { | |
43 | console.log('Main WebSockets connection created.'); |
|
44 | console.log('Main WebSockets connection created.'); | |
44 | }; |
|
45 | }; |
@@ -54,10 +54,11 | |||||
54 | /* This conditional is used to know if we have to setup the data |
|
54 | /* This conditional is used to know if we have to setup the data | |
55 | or just update the last data*/ |
|
55 | or just update the last data*/ | |
56 | $("#loader").css("display", "block"); |
|
56 | $("#loader").css("display", "block"); | |
|
57 | var ws_scheme = window.location.protocol == "https:" ? "wss" : "ws"; | |||
57 | {% if realtime %} |
|
58 | {% if realtime %} | |
58 |
var socket = new WebSocket( |
|
59 | var socket = new WebSocket(ws_scheme + '://' + window.location.host + '/ws/realtime/{{code}}/{{plot}}/'); | |
59 | {% else %} |
|
60 | {% else %} | |
60 |
var socket = new WebSocket( |
|
61 | var socket = new WebSocket(ws_scheme + '://' + window.location.host + '/ws/database/{{code}}/{{plot}}/'); | |
61 | {% endif %} |
|
62 | {% endif %} | |
62 | socket.onopen = function open() { |
|
63 | socket.onopen = function open() { | |
63 | console.log('WebSockets connection created: ' + socket.url); |
|
64 | console.log('WebSockets connection created: ' + socket.url); | |
@@ -102,4 +103,4 | |||||
102 | plt.restyle(values); |
|
103 | plt.restyle(values); | |
103 | }); |
|
104 | }); | |
104 |
|
105 | |||
105 | </script> {% endblock script %} No newline at end of file |
|
106 | </script> {% endblock script %} |
@@ -71,7 +71,7 class SPCSetupForm(forms.Form): | |||||
71 | def main(request, tag=None): |
|
71 | def main(request, tag=None): | |
72 |
|
72 | |||
73 | kwargs = {} |
|
73 | kwargs = {} | |
74 |
date = request.GET.get('date', datetime. |
|
74 | date = request.GET.get('date', datetime.now().strftime('%d-%m-%Y')) | |
75 | exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y')) |
|
75 | exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y')) | |
76 |
|
76 | |||
77 | tmp = {} |
|
77 | tmp = {} | |
@@ -167,7 +167,7 def plot(request, code=None, plot=None): | |||||
167 | realtime = False |
|
167 | realtime = False | |
168 | date = request.GET.get('date', None) |
|
168 | date = request.GET.get('date', None) | |
169 | if date is None: |
|
169 | if date is None: | |
170 |
date = datetime. |
|
170 | date = datetime.now().strftime('%d-%m-%Y') | |
171 | realtime = True |
|
171 | realtime = True | |
172 | exp = Experiment.objects.get(code=int(code)) |
|
172 | exp = Experiment.objects.get(code=int(code)) | |
173 | detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y')) |
|
173 | detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y')) | |
@@ -235,4 +235,4 def plot_overjro(request): | |||||
235 | data = skynoise_plot(date.year, date.month, date.day) |
|
235 | data = skynoise_plot(date.year, date.month, date.day) | |
236 | response = HttpResponse(data.getvalue(), content_type='image/png') |
|
236 | response = HttpResponse(data.getvalue(), content_type='image/png') | |
237 |
|
237 | |||
238 | return response No newline at end of file |
|
238 | return response |
@@ -70,7 +70,7 TEMPLATES = [ | |||||
70 | }, |
|
70 | }, | |
71 | ] |
|
71 | ] | |
72 |
|
72 | |||
73 | WSGI_APPLICATION = 'realtime.wsgi.application' |
|
73 | # WSGI_APPLICATION = 'realtime.wsgi.application' | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | # Database |
|
76 | # Database | |
@@ -121,10 +121,13 USE_TZ = True | |||||
121 | # https://docs.djangoproject.com/en/1.11/howto/static-files/ |
|
121 | # https://docs.djangoproject.com/en/1.11/howto/static-files/ | |
122 |
|
122 | |||
123 | STATIC_URL = '/static/' |
|
123 | STATIC_URL = '/static/' | |
|
124 | STATIC_ROOT = '/static/' | |||
124 |
|
125 | |||
125 | #======================== YONG ================================ |
|
126 | #======================== YONG ================================ | |
126 | host = os.environ.get('HOST_REDIS', '127.0.0.1') |
|
127 | host = os.environ.get('HOST_REDIS', '127.0.0.1') | |
127 |
|
128 | |||
|
129 | ASGI_APPLICATION = 'realtime.asgi.application' | |||
|
130 | ||||
128 | CHANNEL_LAYERS = { |
|
131 | CHANNEL_LAYERS = { | |
129 | "default": { |
|
132 | "default": { | |
130 | 'BACKEND': 'channels_redis.core.RedisChannelLayer', |
|
133 | 'BACKEND': 'channels_redis.core.RedisChannelLayer', | |
@@ -134,4 +137,3 CHANNEL_LAYERS = { | |||||
134 | }, |
|
137 | }, | |
135 | } |
|
138 | } | |
136 |
|
139 | |||
137 | ASGI_APPLICATION = "realtime.routing.application" |
|
@@ -10,4 +10,5 requests | |||||
10 | simplejson |
|
10 | simplejson | |
11 | numpy |
|
11 | numpy | |
12 | matplotlib |
|
12 | matplotlib | |
13 | scipy No newline at end of file |
|
13 | scipy | |
|
14 | gunicorn |
@@ -116,12 +116,16 | |||||
116 | "name" : "JULIA Bistatic" |
|
116 | "name" : "JULIA Bistatic" | |
117 | }, |
|
117 | }, | |
118 | { |
|
118 | { | |
|
119 | "code" : 210, | |||
|
120 | "name" : "High Altitude Drift" | |||
|
121 | }, | |||
|
122 | { | |||
119 | "code" : 230, |
|
123 | "code" : 230, | |
120 | "name" : "Valley Bottonside 150 Km" |
|
124 | "name" : "Valley Bottonside 150 Km" | |
121 | }, |
|
125 | }, | |
122 | { |
|
126 | { | |
123 | "code" : 240, |
|
127 | "code" : 240, | |
124 |
"name" : "Simone |
|
128 | "name" : "Simone Ancon" | |
125 | }, |
|
129 | }, | |
126 | { |
|
130 | { | |
127 | "code" : 241, |
|
131 | "code" : 241, | |
@@ -137,6 +141,6 | |||||
137 | }, |
|
141 | }, | |
138 | { |
|
142 | { | |
139 | "code" : 244, |
|
143 | "code" : 244, | |
140 |
"name" : "Simone |
|
144 | "name" : "Simone Chaclacayo" | |
141 | } |
|
145 | } | |
142 | ] |
|
146 | ] |
@@ -44,7 +44,7 def loaddata(): | |||||
44 |
|
44 | |||
45 | #============== funcion para modificar datos en la tabla ============== |
|
45 | #============== funcion para modificar datos en la tabla ============== | |
46 | def update(buffer): |
|
46 | def update(buffer): | |
47 |
dt = datetime. |
|
47 | dt = datetime.fromtimestamp(buffer['time']) | |
48 | interval = buffer['metadata'].pop('interval') |
|
48 | interval = buffer['metadata'].pop('interval') | |
49 | tag = buffer['metadata'].pop('tag') if 'tag' in buffer['metadata'] else '' |
|
49 | tag = buffer['metadata'].pop('tag') if 'tag' in buffer['metadata'] else '' | |
50 | exp = Experiment.objects.get(code=buffer['code']) |
|
50 | exp = Experiment.objects.get(code=buffer['code']) | |
@@ -129,7 +129,10 def main(): | |||||
129 |
|
129 | |||
130 | while True: |
|
130 | while True: | |
131 |
|
131 | |||
132 | buffer = receiver.recv_json() |
|
132 | try: | |
|
133 | buffer = receiver.recv_json() | |||
|
134 | except: | |||
|
135 | continue | |||
133 | if not isinstance(buffer, dict): |
|
136 | if not isinstance(buffer, dict): | |
134 | print('Invalid data received: {}').format(str(buffer)) |
|
137 | print('Invalid data received: {}').format(str(buffer)) | |
135 | continue |
|
138 | continue |
@@ -119,7 +119,7 class Time: | |||||
119 | Converts datetime to number of seconds respect to 1970. |
|
119 | Converts datetime to number of seconds respect to 1970. | |
120 | """ |
|
120 | """ | |
121 |
|
121 | |||
122 | dtime = dt(self.year, self.month, self.dom) |
|
122 | dtime = dt(self.year[0], self.month[0], self.dom[0]) | |
123 | return (dtime-dt(1970, 1, 1)).total_seconds() |
|
123 | return (dtime-dt(1970, 1, 1)).total_seconds() | |
124 |
|
124 | |||
125 | year = self.year |
|
125 | year = self.year |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now