-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoremusic.yaml
42 lines (42 loc) · 6.09 KB
/
moremusic.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
metadata:
name: moremusic
spec:
handler: "main:handler"
runtime: nodejs
env:
- name: API_KEY_LASTFM
value: "YOUR_API_KEY_HERE"
- name: API_KEY_YOUTUBE
value: "YOUR_API_KEY_HERE"
- name: API_KEY_IFTTT
value: "YOUR_API_KEY_HERE"
- name: IP
value: "YOUR_IP_HERE"
resources: {}
image: "nuclio/processor-moremusic:latest"
minReplicas: 1
maxReplicas: 1
targetCPU: 80
triggers:
themusictrigger:
kind: mqtt
attributes:
subscriptions:
- topic: iot/moremusic
qos: 0
workerAllocatorName: ""
url: "guest:guest@**INSERT HERE YOUR IP**:1883"
version: 1
build:
image: ""
noCache: false
offline: false
dependencies: []
runtimeAttributes:
repositories: []
functionSourceCode: Y29uc3QgYW1xcCA9IHJlcXVpcmUoJ2FtcXBsaWInKTsNCmNvbnN0IGh0dHBzID0gcmVxdWlyZSgnaHR0cHMnKQ0KDQoNCmNvbnN0IFFVRVVFX0xPR0dFUiA9ICdpb3QvbG9nZ2VyJzsNCmNvbnN0IElQID0gcHJvY2Vzcy5lbnYuSVA7DQpjb25zdCBBUElfS0VZX0xBU1RGTSA9IHByb2Nlc3MuZW52LkFQSV9LRVlfTEFTVEZNOw0KY29uc3QgQVBJX0tFWV9ZT1VUVUJFID0gcHJvY2Vzcy5lbnYuQVBJX0tFWV9ZT1VUVUJFOw0KY29uc3QgQVBJX0tFWV9JRlRUVCA9IHByb2Nlc3MuZW52LkFQSV9LRVlfSUZUVFQ7DQoNCg0KbGV0IGJ1aWxkUmVxdWVzdCA9IGZ1bmN0aW9uKHVybCwgZGF0YSkgew0KCWNvbnN0IHBhcmFtcyA9IHR5cGVvZiBkYXRhID09ICdzdHJpbmcnID8gZGF0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hdGEuc3BsaXQoJy0nKS5tYXAoeCA9PiB4LnRyaW0oKSk7DQoNCglpZiAoc29uZy5sZW5ndGggIT0gMikgew0KCQlzZW5kRmVlZGJhY2soYEVycm9yIHdoaWxlIGxvYWRpbmcgdGhlIHNvbmcsICR7X2RhdGF9IGlzIG5vdCB2YWxpZGApDQoJCQkudGhlbih4ID0+IHgpDQoJCXJldHVybg0KCX1lbHNlew0KCQlzZW5kRmVlZGJhY2soYFNvbmcgbG9hZGVkOiAke3Nvbmcuam9pbignIC0gJyl9YCkNCgkJCS50aGVuKHggPT4geCkNCgl9DQoNCglmZXRjaEFQSXMoc29uZykNCgkJLnRoZW4obGlua3MgPT4gc2VuZElGVFRUKGxpbmtzKSkNCgkJLnRoZW4ob3V0cHV0ID0+IGNvbnRleHQuY2FsbGJhY2soIkRvbmUiKSkNCgkJLmNhdGNoKGVyciA9PiBjb250ZXh0LmNhbGxiYWNrKCJFcnJvcjogIiwgZXJyKSk7DQoNCn0=
commands:
- 'npm install amqplib'
codeEntryType: sourceCode
platform: {}
readinessTimeoutSeconds: 60