(self)
| 199 | |
| 200 | class Main: |
| 201 | def start(self): |
| 202 | _fixSocket() |
| 203 | |
| 204 | daemon = BMConfigParser().safeGetBoolean('bitmessagesettings', 'daemon') |
| 205 | |
| 206 | try: |
| 207 | opts, args = getopt.getopt(sys.argv[1:], "hcd", |
| 208 | ["help", "curses", "daemon"]) |
| 209 | |
| 210 | except getopt.GetoptError: |
| 211 | self.usage() |
| 212 | sys.exit(2) |
| 213 | |
| 214 | for opt, arg in opts: |
| 215 | if opt in ("-h", "--help"): |
| 216 | self.usage() |
| 217 | sys.exit() |
| 218 | elif opt in ("-d", "--daemon"): |
| 219 | daemon = True |
| 220 | elif opt in ("-c", "--curses"): |
| 221 | state.curses = True |
| 222 | |
| 223 | # is the application already running? If yes then exit. |
| 224 | shared.thisapp = singleinstance("", daemon) |
| 225 | |
| 226 | if daemon: |
| 227 | with shared.printLock: |
| 228 | print('Running as a daemon. Send TERM signal to end.') |
| 229 | self.daemonize() |
| 230 | |
| 231 | self.setSignalHandler() |
| 232 | |
| 233 | helper_threading.set_thread_name("PyBitmessage") |
| 234 | |
| 235 | state.dandelion = BMConfigParser().safeGetInt('network', 'dandelion') |
| 236 | # dandelion requires outbound connections, without them, stem objects will get stuck forever |
| 237 | if state.dandelion and not BMConfigParser().safeGetBoolean('bitmessagesettings', 'sendoutgoingconnections'): |
| 238 | state.dandelion = 0 |
| 239 | |
| 240 | helper_bootstrap.knownNodes() |
| 241 | # Start the address generation thread |
| 242 | addressGeneratorThread = addressGenerator() |
| 243 | addressGeneratorThread.daemon = True # close the main program even if there are threads left |
| 244 | addressGeneratorThread.start() |
| 245 | |
| 246 | # Start the thread that calculates POWs |
| 247 | singleWorkerThread = singleWorker() |
| 248 | singleWorkerThread.daemon = True # close the main program even if there are threads left |
| 249 | singleWorkerThread.start() |
| 250 | |
| 251 | # Start the SQL thread |
| 252 | sqlLookup = sqlThread() |
| 253 | sqlLookup.daemon = False # DON'T close the main program even if there are threads left. The closeEvent should command this thread to exit gracefully. |
| 254 | sqlLookup.start() |
| 255 | |
| 256 | Inventory() # init |
| 257 | Dandelion() # init, needs to be early because other thread may access it early |
| 258 |
no test coverage detected