diff options
author | Erik Johnston <erik@matrix.org> | 2017-10-02 18:11:24 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-10-02 18:11:24 +0100 |
commit | e585c83209349d2d6e679cccc9f916edd2df1728 (patch) | |
tree | 4b54914df6bfee4cfcf0a0dcbe4b2393d8f0ea4f /synapse/app/_base.py | |
parent | Merge branch 'master' of github.com:matrix-org/synapse into develop (diff) | |
parent | Bump version and changelog (diff) | |
download | synapse-e585c83209349d2d6e679cccc9f916edd2df1728.tar.xz |
Merge branch 'master' of github.com:matrix-org/synapse into develop
Diffstat (limited to 'synapse/app/_base.py')
-rw-r--r-- | synapse/app/_base.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/synapse/app/_base.py b/synapse/app/_base.py index cd0e815919..cf4730730d 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -12,10 +12,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import gc import logging +import sys + +try: + import affinity +except: + affinity = None -import affinity from daemonize import Daemonize from synapse.util import PreserveLoggingContext from synapse.util.rlimit import change_resource_limit @@ -78,6 +84,13 @@ def start_reactor( with PreserveLoggingContext(): logger.info("Running") if cpu_affinity is not None: + if not affinity: + quit_with_error( + "Missing package 'affinity' required for cpu_affinity\n" + "option\n\n" + "Install by running:\n\n" + " pip install affinity\n\n" + ) logger.info("Setting CPU affinity to %s" % cpu_affinity) affinity.set_process_affinity_mask(0, cpu_affinity) change_resource_limit(soft_file_limit) @@ -97,3 +110,13 @@ def start_reactor( daemon.start() else: run() + + +def quit_with_error(error_string): + message_lines = error_string.split("\n") + line_length = max([len(l) for l in message_lines if len(l) < 80]) + 2 + sys.stderr.write("*" * line_length + '\n') + for line in message_lines: + sys.stderr.write(" %s\n" % (line.rstrip(),)) + sys.stderr.write("*" * line_length + '\n') + sys.exit(1) |