2020-01-28 10:31:31 +01:00
|
|
|
#!/usr/bin/env python
|
2019-11-04 15:44:45 +01:00
|
|
|
"""
|
|
|
|
The PyBitmessage startup script
|
|
|
|
"""
|
2016-05-01 08:34:04 +02:00
|
|
|
# Copyright (c) 2012-2016 Jonathan Warren
|
2022-01-17 18:11:23 +01:00
|
|
|
# Copyright (c) 2012-2022 The Bitmessage developers
|
2012-11-19 20:45:05 +01:00
|
|
|
# Distributed under the MIT/X11 software license. See the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2013-06-13 20:00:56 +02:00
|
|
|
# Right now, PyBitmessage only support connecting to stream 1. It doesn't
|
|
|
|
# yet contain logic to expand into further streams.
|
2017-02-28 14:51:49 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2021-01-31 21:23:55 +01:00
|
|
|
try:
|
|
|
|
import pathmagic
|
|
|
|
except ImportError:
|
|
|
|
from pybitmessage import pathmagic
|
|
|
|
app_dir = pathmagic.setup()
|
2017-09-27 17:25:14 +02:00
|
|
|
|
2014-08-06 08:40:41 +02:00
|
|
|
import depends
|
|
|
|
depends.check_dependencies()
|
2014-07-29 08:51:59 +02:00
|
|
|
|
2018-06-28 15:09:23 +02:00
|
|
|
import getopt
|
2019-03-06 17:51:23 +01:00
|
|
|
import multiprocessing
|
2017-09-27 17:25:14 +02:00
|
|
|
# Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
|
|
|
|
import signal
|
2019-03-06 17:51:23 +01:00
|
|
|
import threading
|
2018-04-10 17:29:39 +02:00
|
|
|
import time
|
2019-03-06 17:51:23 +01:00
|
|
|
import traceback
|
2013-05-01 22:06:55 +02:00
|
|
|
|
2017-02-08 20:37:42 +01:00
|
|
|
import defaults
|
2020-11-14 16:00:00 +01:00
|
|
|
# Network subsystem
|
|
|
|
import network
|
2013-12-30 01:53:44 +01:00
|
|
|
import shared
|
2017-02-08 13:41:56 +01:00
|
|
|
import shutdown
|
2020-01-24 15:03:13 +01:00
|
|
|
import state
|
2021-10-15 16:00:19 +02:00
|
|
|
|
|
|
|
from testmode_init import populate_api_test_data
|
2022-01-28 13:55:23 +01:00
|
|
|
from bmconfigparser import config
|
2019-10-27 14:15:45 +01:00
|
|
|
from debug import logger # this should go before any threads
|
2019-11-03 13:13:18 +01:00
|
|
|
from helper_startup import (
|
2020-02-20 14:09:52 +01:00
|
|
|
adjustHalfOpenConnectionsLimit, fixSocket, start_proxyconfig)
|
2017-05-27 19:09:21 +02:00
|
|
|
from inventory import Inventory
|
2019-11-03 13:13:18 +01:00
|
|
|
from singleinstance import singleinstance
|
2019-10-27 14:15:45 +01:00
|
|
|
# Synchronous threads
|
|
|
|
from threads import (
|
2019-11-05 17:54:04 +01:00
|
|
|
set_thread_name, printLock,
|
|
|
|
addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread)
|
2015-11-15 15:08:48 +01:00
|
|
|
|
2019-03-06 17:51:23 +01:00
|
|
|
|
2019-03-06 21:36:34 +01:00
|
|
|
def signal_handler(signum, frame):
|
|
|
|
"""Single handler for any signal sent to pybitmessage"""
|
2019-03-06 17:51:23 +01:00
|
|
|
process = multiprocessing.current_process()
|
2019-03-06 21:36:34 +01:00
|
|
|
thread = threading.current_thread()
|
2019-03-06 17:51:23 +01:00
|
|
|
logger.error(
|
|
|
|
'Got signal %i in %s/%s',
|
2019-03-06 21:36:34 +01:00
|
|
|
signum, process.name, thread.name
|
2019-03-06 17:51:23 +01:00
|
|
|
)
|
|
|
|
if process.name == "RegExParser":
|
|
|
|
# on Windows this isn't triggered, but it's fine,
|
|
|
|
# it has its own process termination thing
|
|
|
|
raise SystemExit
|
|
|
|
if "PoolWorker" in process.name:
|
|
|
|
raise SystemExit
|
2019-03-06 21:36:34 +01:00
|
|
|
if thread.name not in ("PyBitmessage", "MainThread"):
|
2019-03-06 17:51:23 +01:00
|
|
|
return
|
2019-03-06 21:36:34 +01:00
|
|
|
logger.error("Got signal %i", signum)
|
2020-01-17 14:27:36 +01:00
|
|
|
# there are possible non-UI variants to run bitmessage
|
|
|
|
# which should shutdown especially test-mode
|
2019-11-05 17:54:04 +01:00
|
|
|
if state.thisapp.daemon or not state.enableGUI:
|
2019-03-06 17:51:23 +01:00
|
|
|
shutdown.doCleanShutdown()
|
|
|
|
else:
|
2019-03-06 21:36:34 +01:00
|
|
|
print('# Thread: %s(%d)' % (thread.name, thread.ident))
|
|
|
|
for filename, lineno, name, line in traceback.extract_stack(frame):
|
|
|
|
print('File: "%s", line %d, in %s' % (filename, lineno, name))
|
|
|
|
if line:
|
|
|
|
print(' %s' % line.strip())
|
2019-03-06 17:51:23 +01:00
|
|
|
print('Unfortunately you cannot use Ctrl+C when running the UI'
|
|
|
|
' because the UI captures the signal.')
|
|
|
|
|
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
class Main(object):
|
|
|
|
"""Main PyBitmessage class"""
|
2019-10-18 16:52:44 +02:00
|
|
|
def start(self):
|
2019-11-04 15:44:45 +01:00
|
|
|
"""Start main application"""
|
2019-10-18 16:52:44 +02:00
|
|
|
# pylint: disable=too-many-statements,too-many-branches,too-many-locals
|
2020-02-20 14:09:52 +01:00
|
|
|
fixSocket()
|
2020-01-24 17:23:59 +01:00
|
|
|
adjustHalfOpenConnectionsLimit()
|
2014-02-16 17:21:20 +01:00
|
|
|
|
2019-07-23 17:55:14 +02:00
|
|
|
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
|
2017-09-26 16:36:02 +02:00
|
|
|
|
2017-09-23 23:42:15 +02:00
|
|
|
try:
|
2019-11-04 15:44:45 +01:00
|
|
|
opts, _ = getopt.getopt(
|
2018-03-23 15:56:01 +01:00
|
|
|
sys.argv[1:], "hcdt",
|
|
|
|
["help", "curses", "daemon", "test"])
|
2017-09-23 23:42:15 +02:00
|
|
|
|
|
|
|
except getopt.GetoptError:
|
|
|
|
self.usage()
|
|
|
|
sys.exit(2)
|
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
for opt, _ in opts:
|
2017-09-23 23:42:15 +02:00
|
|
|
if opt in ("-h", "--help"):
|
|
|
|
self.usage()
|
|
|
|
sys.exit()
|
|
|
|
elif opt in ("-d", "--daemon"):
|
|
|
|
daemon = True
|
|
|
|
elif opt in ("-c", "--curses"):
|
|
|
|
state.curses = True
|
2018-04-05 11:50:34 +02:00
|
|
|
elif opt in ("-t", "--test"):
|
2018-04-16 09:00:23 +02:00
|
|
|
state.testmode = True
|
|
|
|
if os.path.isfile(os.path.join(
|
|
|
|
state.appdata, 'unittest.lock')):
|
|
|
|
daemon = True
|
2017-09-27 17:25:14 +02:00
|
|
|
state.enableGUI = False # run without a UI
|
2018-04-10 17:29:39 +02:00
|
|
|
# Fallback: in case when no api command was issued
|
|
|
|
state.last_api_response = time.time()
|
|
|
|
# Apply special settings
|
|
|
|
config.set(
|
|
|
|
'bitmessagesettings', 'apienabled', 'true')
|
|
|
|
config.set(
|
|
|
|
'bitmessagesettings', 'apiusername', 'username')
|
|
|
|
config.set(
|
|
|
|
'bitmessagesettings', 'apipassword', 'password')
|
2018-10-25 11:52:16 +02:00
|
|
|
config.set(
|
|
|
|
'bitmessagesettings', 'apivariant', 'legacy')
|
2018-04-10 17:29:39 +02:00
|
|
|
config.set(
|
|
|
|
'bitmessagesettings', 'apinotifypath',
|
|
|
|
os.path.join(app_dir, 'tests', 'apinotify_handler.py')
|
|
|
|
)
|
2013-08-06 13:23:56 +02:00
|
|
|
|
2018-11-04 14:00:27 +01:00
|
|
|
if daemon:
|
|
|
|
state.enableGUI = False # run without a UI
|
|
|
|
|
2018-05-22 13:17:47 +02:00
|
|
|
if state.enableGUI and not state.curses and not depends.check_pyqt():
|
|
|
|
sys.exit(
|
|
|
|
'PyBitmessage requires PyQt unless you want'
|
|
|
|
' to run it as a daemon and interact with it'
|
|
|
|
' using the API. You can download PyQt from '
|
|
|
|
'http://www.riverbankcomputing.com/software/pyqt/download'
|
|
|
|
' or by searching Google for \'PyQt Download\'.'
|
|
|
|
' If you want to run in daemon mode, see '
|
|
|
|
'https://bitmessage.org/wiki/Daemon\n'
|
|
|
|
'You can also run PyBitmessage with'
|
|
|
|
' the new curses interface by providing'
|
|
|
|
' \'-c\' as a commandline argument.'
|
|
|
|
)
|
2018-11-04 14:00:27 +01:00
|
|
|
# is the application already running? If yes then exit.
|
2019-11-05 17:54:04 +01:00
|
|
|
state.thisapp = singleinstance("", daemon)
|
2016-06-30 12:30:05 +02:00
|
|
|
|
2018-04-10 17:29:39 +02:00
|
|
|
if daemon:
|
2019-11-05 17:54:04 +01:00
|
|
|
with printLock:
|
2016-06-30 12:30:05 +02:00
|
|
|
print('Running as a daemon. Send TERM signal to end.')
|
|
|
|
self.daemonize()
|
|
|
|
|
|
|
|
self.setSignalHandler()
|
2013-08-06 13:23:56 +02:00
|
|
|
|
2019-10-27 14:15:45 +01:00
|
|
|
set_thread_name("PyBitmessage")
|
2017-07-06 19:35:40 +02:00
|
|
|
|
2019-07-23 17:55:14 +02:00
|
|
|
state.dandelion = config.safeGetInt('network', 'dandelion')
|
2017-09-27 17:25:14 +02:00
|
|
|
# dandelion requires outbound connections, without them,
|
|
|
|
# stem objects will get stuck forever
|
2019-07-23 17:55:14 +02:00
|
|
|
if state.dandelion and not config.safeGetBoolean(
|
2017-09-27 17:25:14 +02:00
|
|
|
'bitmessagesettings', 'sendoutgoingconnections'):
|
2018-02-03 11:46:39 +01:00
|
|
|
state.dandelion = 0
|
|
|
|
|
2019-07-23 17:55:14 +02:00
|
|
|
if state.testmode or config.safeGetBoolean(
|
2019-03-07 13:21:07 +01:00
|
|
|
'bitmessagesettings', 'extralowdifficulty'):
|
|
|
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte = int(
|
|
|
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte / 100)
|
|
|
|
defaults.networkDefaultPayloadLengthExtraBytes = int(
|
|
|
|
defaults.networkDefaultPayloadLengthExtraBytes / 100)
|
|
|
|
|
2020-11-14 16:00:00 +01:00
|
|
|
# Start the SQL thread
|
|
|
|
sqlLookup = sqlThread()
|
|
|
|
# DON'T close the main program even if there are threads left.
|
|
|
|
# The closeEvent should command this thread to exit gracefully.
|
|
|
|
sqlLookup.daemon = False
|
|
|
|
sqlLookup.start()
|
2013-08-06 13:23:56 +02:00
|
|
|
|
2020-11-14 16:00:00 +01:00
|
|
|
Inventory() # init
|
|
|
|
|
|
|
|
if state.enableObjProc: # Not needed if objproc is disabled
|
|
|
|
shared.reloadMyAddressHashes()
|
|
|
|
shared.reloadBroadcastSendersForWhichImWatching()
|
2018-04-09 06:38:48 +02:00
|
|
|
|
|
|
|
# Start the address generation thread
|
|
|
|
addressGeneratorThread = addressGenerator()
|
2017-09-27 17:25:14 +02:00
|
|
|
# close the main program even if there are threads left
|
|
|
|
addressGeneratorThread.daemon = True
|
2018-04-09 06:38:48 +02:00
|
|
|
addressGeneratorThread.start()
|
|
|
|
|
|
|
|
# Start the thread that calculates POWs
|
|
|
|
singleWorkerThread = singleWorker()
|
2017-09-27 17:25:14 +02:00
|
|
|
# close the main program even if there are threads left
|
|
|
|
singleWorkerThread.daemon = True
|
2018-04-09 06:38:48 +02:00
|
|
|
singleWorkerThread.start()
|
2013-08-06 13:23:56 +02:00
|
|
|
|
2020-11-14 16:00:00 +01:00
|
|
|
# Start the object processing thread
|
|
|
|
objectProcessorThread = objectProcessor()
|
|
|
|
# DON'T close the main program even if the thread remains.
|
|
|
|
# This thread checks the shutdown variable after processing
|
|
|
|
# each object.
|
|
|
|
objectProcessorThread.daemon = False
|
|
|
|
objectProcessorThread.start()
|
2018-04-09 06:38:48 +02:00
|
|
|
|
|
|
|
# SMTP delivery thread
|
2019-07-23 17:55:14 +02:00
|
|
|
if daemon and config.safeGet(
|
|
|
|
'bitmessagesettings', 'smtpdeliver', '') != '':
|
2018-06-21 12:03:50 +02:00
|
|
|
from class_smtpDeliver import smtpDeliver
|
2018-04-09 06:38:48 +02:00
|
|
|
smtpDeliveryThread = smtpDeliver()
|
|
|
|
smtpDeliveryThread.start()
|
2016-06-30 12:30:05 +02:00
|
|
|
|
2018-04-09 06:38:48 +02:00
|
|
|
# SMTP daemon thread
|
2019-07-23 17:55:14 +02:00
|
|
|
if daemon and config.safeGetBoolean(
|
|
|
|
'bitmessagesettings', 'smtpd'):
|
2018-06-21 12:03:50 +02:00
|
|
|
from class_smtpServer import smtpServer
|
2018-04-09 06:38:48 +02:00
|
|
|
smtpServerThread = smtpServer()
|
|
|
|
smtpServerThread.start()
|
2016-07-19 13:57:54 +02:00
|
|
|
|
2018-04-09 06:38:48 +02:00
|
|
|
# API is also objproc dependent
|
2019-07-23 17:55:14 +02:00
|
|
|
if config.safeGetBoolean('bitmessagesettings', 'apienabled'):
|
2018-09-05 12:56:06 +02:00
|
|
|
import api # pylint: disable=relative-import
|
2018-06-28 15:09:23 +02:00
|
|
|
singleAPIThread = api.singleAPI()
|
2017-09-27 17:25:14 +02:00
|
|
|
# close the main program even if there are threads left
|
|
|
|
singleAPIThread.daemon = True
|
2018-04-09 06:38:48 +02:00
|
|
|
singleAPIThread.start()
|
|
|
|
|
2020-11-14 16:00:00 +01:00
|
|
|
# Start the cleanerThread
|
|
|
|
singleCleanerThread = singleCleaner()
|
|
|
|
# close the main program even if there are threads left
|
|
|
|
singleCleanerThread.daemon = True
|
|
|
|
singleCleanerThread.start()
|
|
|
|
|
2018-04-09 06:38:48 +02:00
|
|
|
# start network components if networking is enabled
|
|
|
|
if state.enableNetwork:
|
2019-10-18 16:52:44 +02:00
|
|
|
start_proxyconfig()
|
2021-03-03 10:51:05 +01:00
|
|
|
network.start(config, state)
|
|
|
|
|
2019-07-23 17:55:14 +02:00
|
|
|
if config.safeGetBoolean('bitmessagesettings', 'upnp'):
|
2018-04-09 06:38:48 +02:00
|
|
|
import upnp
|
|
|
|
upnpThread = upnp.uPnPThread()
|
|
|
|
upnpThread.start()
|
|
|
|
else:
|
|
|
|
# Populate with hardcoded value (same as connectToStream above)
|
|
|
|
state.streamsInWhichIAmParticipating.append(1)
|
|
|
|
|
2018-07-09 14:06:28 +02:00
|
|
|
if not daemon and state.enableGUI:
|
2017-09-27 17:25:14 +02:00
|
|
|
if state.curses:
|
2018-05-22 13:17:47 +02:00
|
|
|
if not depends.check_curses():
|
|
|
|
sys.exit()
|
2017-09-27 17:25:14 +02:00
|
|
|
print('Running with curses')
|
|
|
|
import bitmessagecurses
|
|
|
|
bitmessagecurses.runwrapper()
|
2018-05-22 13:17:47 +02:00
|
|
|
else:
|
2014-04-19 20:45:37 +02:00
|
|
|
import bitmessageqt
|
|
|
|
bitmessageqt.run()
|
2018-07-05 15:37:16 +02:00
|
|
|
else:
|
2019-07-23 17:55:14 +02:00
|
|
|
config.remove_option('bitmessagesettings', 'dontconnect')
|
2021-10-15 16:00:19 +02:00
|
|
|
|
|
|
|
if state.testmode:
|
|
|
|
populate_api_test_data()
|
2013-05-02 22:55:13 +02:00
|
|
|
|
2017-07-30 09:36:20 +02:00
|
|
|
if daemon:
|
|
|
|
while state.shutdown == 0:
|
2018-04-10 17:29:39 +02:00
|
|
|
time.sleep(1)
|
2019-08-29 12:03:14 +02:00
|
|
|
if (
|
2020-06-09 16:14:26 +02:00
|
|
|
state.testmode
|
|
|
|
and time.time() - state.last_api_response >= 30
|
2020-01-17 14:27:36 +01:00
|
|
|
):
|
2018-04-10 17:29:39 +02:00
|
|
|
self.stop()
|
2018-04-16 09:00:23 +02:00
|
|
|
elif not state.enableGUI:
|
2020-06-09 16:14:26 +02:00
|
|
|
state.enableGUI = True
|
2020-10-22 12:23:11 +02:00
|
|
|
try:
|
|
|
|
# pylint: disable=relative-import
|
|
|
|
from tests import core as test_core
|
|
|
|
except ImportError:
|
2022-07-28 00:35:48 +02:00
|
|
|
try:
|
|
|
|
from pybitmessage.tests import core as test_core
|
|
|
|
except ImportError:
|
|
|
|
self.stop()
|
|
|
|
return
|
2020-10-22 12:23:11 +02:00
|
|
|
|
2019-10-18 16:52:44 +02:00
|
|
|
test_core_result = test_core.run()
|
2018-04-16 09:00:23 +02:00
|
|
|
self.stop()
|
2018-10-03 17:42:12 +02:00
|
|
|
test_core.cleanup()
|
2021-02-06 20:07:42 +01:00
|
|
|
sys.exit(not test_core_result.wasSuccessful())
|
2017-07-30 09:36:20 +02:00
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
@staticmethod
|
|
|
|
def daemonize():
|
|
|
|
"""Running as a daemon. Send signal in end."""
|
2018-01-01 13:08:12 +01:00
|
|
|
grandfatherPid = os.getpid()
|
|
|
|
parentPid = None
|
2017-07-28 08:54:34 +02:00
|
|
|
try:
|
|
|
|
if os.fork():
|
2018-01-01 13:08:12 +01:00
|
|
|
# unlock
|
2019-11-05 17:54:04 +01:00
|
|
|
state.thisapp.cleanup()
|
2018-01-01 13:08:12 +01:00
|
|
|
# wait until grandchild ready
|
|
|
|
while True:
|
2018-04-10 17:29:39 +02:00
|
|
|
time.sleep(1)
|
2020-01-15 11:47:26 +01:00
|
|
|
os._exit(0) # pylint: disable=protected-access
|
2017-07-28 08:54:34 +02:00
|
|
|
except AttributeError:
|
|
|
|
# fork not implemented
|
|
|
|
pass
|
|
|
|
else:
|
2018-01-01 13:08:12 +01:00
|
|
|
parentPid = os.getpid()
|
2019-11-05 17:54:04 +01:00
|
|
|
state.thisapp.lock() # relock
|
2017-09-27 17:25:14 +02:00
|
|
|
|
2016-06-30 12:30:05 +02:00
|
|
|
os.umask(0)
|
2017-07-28 09:19:53 +02:00
|
|
|
try:
|
|
|
|
os.setsid()
|
|
|
|
except AttributeError:
|
|
|
|
# setsid not implemented
|
|
|
|
pass
|
2017-07-28 08:54:34 +02:00
|
|
|
try:
|
|
|
|
if os.fork():
|
2018-01-01 13:08:12 +01:00
|
|
|
# unlock
|
2019-11-05 17:54:04 +01:00
|
|
|
state.thisapp.cleanup()
|
2018-01-01 13:08:12 +01:00
|
|
|
# wait until child ready
|
|
|
|
while True:
|
2018-04-10 17:29:39 +02:00
|
|
|
time.sleep(1)
|
2020-01-15 11:47:26 +01:00
|
|
|
os._exit(0) # pylint: disable=protected-access
|
2017-07-28 08:54:34 +02:00
|
|
|
except AttributeError:
|
|
|
|
# fork not implemented
|
|
|
|
pass
|
|
|
|
else:
|
2019-11-05 17:54:04 +01:00
|
|
|
state.thisapp.lock() # relock
|
|
|
|
state.thisapp.lockPid = None # indicate we're the final child
|
2016-06-30 12:30:05 +02:00
|
|
|
sys.stdout.flush()
|
|
|
|
sys.stderr.flush()
|
2017-09-23 18:25:41 +02:00
|
|
|
if not sys.platform.startswith('win'):
|
2021-08-19 10:49:40 +02:00
|
|
|
si = open(os.devnull, 'r')
|
|
|
|
so = open(os.devnull, 'a+')
|
|
|
|
se = open(os.devnull, 'a+', 0)
|
2017-09-23 18:25:41 +02:00
|
|
|
os.dup2(si.fileno(), sys.stdin.fileno())
|
|
|
|
os.dup2(so.fileno(), sys.stdout.fileno())
|
|
|
|
os.dup2(se.fileno(), sys.stderr.fileno())
|
2018-01-01 13:08:12 +01:00
|
|
|
if parentPid:
|
|
|
|
# signal ready
|
|
|
|
os.kill(parentPid, signal.SIGTERM)
|
|
|
|
os.kill(grandfatherPid, signal.SIGTERM)
|
2016-06-30 12:30:05 +02:00
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
@staticmethod
|
|
|
|
def setSignalHandler():
|
|
|
|
"""Setting the Signal Handler"""
|
2019-03-06 17:51:23 +01:00
|
|
|
signal.signal(signal.SIGINT, signal_handler)
|
|
|
|
signal.signal(signal.SIGTERM, signal_handler)
|
2016-06-30 12:30:05 +02:00
|
|
|
# signal.signal(signal.SIGINT, signal.SIG_DFL)
|
2013-09-28 14:09:15 +02:00
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
@staticmethod
|
|
|
|
def usage():
|
|
|
|
"""Displaying the usages"""
|
|
|
|
print('Usage: ' + sys.argv[0] + ' [OPTIONS]')
|
|
|
|
print('''
|
2017-09-23 23:42:15 +02:00
|
|
|
Options:
|
|
|
|
-h, --help show this help message and exit
|
|
|
|
-c, --curses use curses (text mode) interface
|
|
|
|
-d, --daemon run in daemon (background) mode
|
2018-03-23 15:56:01 +01:00
|
|
|
-t, --test dryrun, make testing
|
2017-09-23 23:42:15 +02:00
|
|
|
|
|
|
|
All parameters are optional.
|
2019-11-04 15:44:45 +01:00
|
|
|
''')
|
2017-09-23 23:42:15 +02:00
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
@staticmethod
|
|
|
|
def stop():
|
|
|
|
"""Stop main application"""
|
2019-11-05 17:54:04 +01:00
|
|
|
with printLock:
|
2014-07-29 08:51:59 +02:00
|
|
|
print('Stopping Bitmessage Deamon.')
|
2017-02-08 13:41:56 +01:00
|
|
|
shutdown.doCleanShutdown()
|
2013-09-28 14:09:15 +02:00
|
|
|
|
2019-11-04 15:44:45 +01:00
|
|
|
# .. todo:: nice function but no one is using this
|
|
|
|
@staticmethod
|
|
|
|
def getApiAddress():
|
|
|
|
"""This function returns API address and port"""
|
2022-01-28 13:55:23 +01:00
|
|
|
if not config.safeGetBoolean(
|
2017-09-27 17:25:14 +02:00
|
|
|
'bitmessagesettings', 'apienabled'):
|
2013-08-06 13:23:56 +02:00
|
|
|
return None
|
2022-01-28 13:55:23 +01:00
|
|
|
address = config.get('bitmessagesettings', 'apiinterface')
|
|
|
|
port = config.getint('bitmessagesettings', 'apiport')
|
2017-09-27 17:25:14 +02:00
|
|
|
return {'address': address, 'port': port}
|
2013-09-28 14:09:15 +02:00
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
|
|
|
|
def main():
|
2019-11-04 15:44:45 +01:00
|
|
|
"""Triggers main module"""
|
2013-08-06 13:23:56 +02:00
|
|
|
mainprogram = Main()
|
2017-09-26 16:36:02 +02:00
|
|
|
mainprogram.start()
|
2017-02-28 14:51:49 +01:00
|
|
|
|
2017-09-27 17:25:14 +02:00
|
|
|
|
2017-02-28 14:51:49 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
2013-02-18 21:22:48 +01:00
|
|
|
|
2013-09-28 14:09:15 +02:00
|
|
|
|
2013-06-17 22:42:30 +02:00
|
|
|
# So far, the creation of and management of the Bitmessage protocol and this
|
|
|
|
# client is a one-man operation. Bitcoin tips are quite appreciated.
|
2012-11-29 11:39:39 +01:00
|
|
|
# 1H5XaDA6fYENLbknwZyjiYXYPQaFjjLX2u
|