Skip to content

Commit

Permalink
remove push service
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Jun 14, 2024
1 parent 4205a33 commit 79dfe77
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 75 deletions.
9 changes: 0 additions & 9 deletions app/models/storer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def store device, reading, do_update = true

if do_update
update_device(device, parsed_reading[:parsed_ts], parsed_reading[:sql_data])
ws_publish(device)
end

forward_reading(device, reading)
Expand Down Expand Up @@ -49,14 +48,6 @@ def kairos_publish(reading_data)
Redis.current.publish('telnet_queue', reading_data.to_json)
end

def ws_publish(device)
return if Rails.env.test? or device.blank?
begin
Redis.current.publish("data-received", renderer.render( partial: "v0/devices/device", locals: {device: device, current_user: nil}))
rescue
end
end

private

attr_reader :mqtt_client, :renderer
Expand Down
2 changes: 0 additions & 2 deletions compose.override.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ services:
restart: "no"
telnet-task:
restart: "no"
push:
restart: "no"
grafana:
entrypoint: ["echo", "Grafana service disabled in development"]
restart: "no"
3 changes: 1 addition & 2 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ include:
- compose/telnet-task.yml
- compose/mqtt.yml
- compose/web.yml
- compose/push.yml
- compose/kairos.yml
- compose/cassandra.yml
- compose/grafana.yml
- compose/grafana.yml
3 changes: 1 addition & 2 deletions compose/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ services:
- sidekiq
- mqtt-task
- telnet-task
- push
#- mqtt
restart: always
deploy:
Expand All @@ -34,4 +33,4 @@ services:
logging:
driver: "json-file"
options:
max-size: "100m"
max-size: "100m"
28 changes: 0 additions & 28 deletions docs/onboarding.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,34 +174,6 @@ This is tiggered when the platform receives the first **"Hello World"** from the

http://codepen.io/pral2a/pen/ObMWjG

### Angular Integration:

The SmartCitizen front-end features already a `push.service.js` that can be extended with minor changes:

https://github.com/fablabbcn/smartcitizen-web/blob/2e08faca25675970d56c0b5cc090670ffff73d47/src/app/core/api/push.service.js

This needs to extend as follows:

```
function devicesToken(then){
socket.on('token-received', then);
}
function deviceToken(tokenID, scope){
devicesToken(function(data){
if(tokenID == data.device_token) scope.$emit('token', data);
})
}
```

And use as follows:

`push.token(vm.kitData.token, $scope);`

By including the following service we will be also able to listen notification everytime the Kit published new data:

`push.device(vm.kitData.id, $scope);`




Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# Always pull from master? What if staging should deploy 'dev' branch?
git pull origin master;
docker compose pull auth push;
docker compose pull auth;
# Accept containers as params. Supports starting only 'app db' f.x.
docker compose build && docker compose up -d $@

Expand Down
31 changes: 3 additions & 28 deletions scripts/nginx-conf/api.smartcitizen.me.conf
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
upstream docker-push {
server push:8000;
}

server {

listen 80;
listen [::]:80;

listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/star_smartcitizen_me.pem;
ssl_certificate_key /etc/ssl/star_smartcitizen_me.key;

server_name staging-ws.smartcitizen.me ws.smartcitizen.me;

location / {
proxy_pass http://docker-push;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}

server {
server_name kairos.smartcitizen.me staging-kairos.smartcitizen.me;

listen 80;
listen [::]:80;

listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/star_smartcitizen_me.pem;
Expand All @@ -47,7 +22,7 @@ server {

listen 80;
listen [::]:80;

listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/star_smartcitizen_me.pem;
Expand Down Expand Up @@ -96,7 +71,7 @@ server {

listen 80;
listen [::]:80;

listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/star_smartcitizen_me.pem;
Expand Down
3 changes: 0 additions & 3 deletions spec/models/storer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
it 'stores data to device' do
# model/storer.rb is not using Kairos, but Redis -> Telnet
# expect(Kairos).to receive(:http_post_to).with("/datapoints", @karios_data)
# expect_any_instance_of(Storer).to receive(:ws_publish)
expect do
storer.store(device, @data)
end.not_to raise_error
Expand All @@ -73,8 +72,6 @@
skip 'updates device without touching updated_at' do
updated_at = device.updated_at

expect(storer).to receive(:ws_publish)

storer.store(device, @data)

expect(device.reload.updated_at).to eq(updated_at)
Expand Down

0 comments on commit 79dfe77

Please sign in to comment.