Browse Source

Merge "Prevent more than one gertty from running at a time"

changes/91/391991/1
Jenkins 5 years ago
committed by Gerrit Code Review
parent
commit
3addba09e7
2 changed files with 10 additions and 0 deletions
  1. +8
    -0
      gertty/app.py
  2. +2
    -0
      gertty/config.py

+ 8
- 0
gertty/app.py View File

@ -16,6 +16,7 @@
import argparse
import datetime
import dateutil
import fcntl
import functools
import logging
import os
@ -274,6 +275,13 @@ class App(object):
self.log = logging.getLogger('gertty.App')
self.log.debug("Starting")
self.lock_fd = open(self.config.lock_file, 'w')
try:
fcntl.lockf(self.lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
print("error: another instance of gertty is running for: %s" % self.config.server['name'])
sys.exit(1)
self.project_cache = ProjectCache()
self.ring = mywid.KillRing()
self.input_buffer = []


+ 2
- 0
gertty/config.py View File

@ -186,6 +186,8 @@ class Config(object):
self.socket_path = os.path.expanduser(socket_path)
log_file = server.get('log-file', '~/.gertty.log')
self.log_file = os.path.expanduser(log_file)
lock_file = server.get('lock-file', '~/.gertty.%s.lock' % server['name'])
self.lock_file = os.path.expanduser(lock_file)
self.palettes = {'default': gertty.palette.Palette({}),
'light': gertty.palette.Palette(gertty.palette.LIGHT_PALETTE),


Loading…
Cancel
Save