-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathservice.py
38 lines (29 loc) · 1.03 KB
/
service.py
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
# This is a bare-minimum service plugin
# example that you can build upon to
# implement your own service plugins.
import RNS
import time
import threading
class BasicServicePlugin(SidebandServicePlugin):
service_name = "service_example"
def service_jobs(self):
while self.should_run:
time.sleep(5)
RNS.log("Service ping from "+str(self))
RNS.log("Jobs stopped running for "+str(self))
def start(self):
# Do any initialisation work here
RNS.log("Basic service plugin example starting...")
self.should_run = True
self.service_thread = threading.Thread(target=self.service_jobs, daemon=True)
self.service_thread.start()
# And finally call start on superclass
super().start()
def stop(self):
# Do any teardown work here
self.should_run = False
# And finally call stop on superclass
super().stop()
# Finally, tell Sideband what class in this
# file is the actual plugin class.
plugin_class = BasicServicePlugin