Total Complexity | 3 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | '''shut down a miner''' |
||
2 | from helpers.queuehelper import QueueName |
||
3 | from helpers.antminerhelper import shutdown |
||
4 | from backend.fcmapp import Component |
||
5 | |||
6 | SHUTDOWN = Component('shutdown') |
||
7 | |||
8 | def when_shutdown(channel, method, properties, body): |
||
9 | msg = SHUTDOWN.app.messagedecodeminer(body) |
||
10 | miner = msg.miner |
||
11 | minercommand = msg.command |
||
12 | #sanity check |
||
13 | if minercommand.command == 'shutdown': |
||
14 | #here you implement specific logic to shutdown your miner |
||
15 | shutdown(miner, SHUTDOWN.app.sshlogin()) |
||
16 | |||
17 | def main(): |
||
18 | SHUTDOWN.listeningqueue = SHUTDOWN.app.subscribe(QueueName.Q_SHUTDOWN, when_shutdown, no_acknowledge=True) |
||
19 | SHUTDOWN.app.listen(SHUTDOWN.listeningqueue) |
||
20 | |||
21 | if __name__ == "__main__": |
||
22 | main() |
||
23 |