Merge "Prevent more than one gertty from running at a time"
This commit is contained in:
commit
3addba09e7
@ -16,6 +16,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import dateutil
|
import dateutil
|
||||||
|
import fcntl
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -274,6 +275,13 @@ class App(object):
|
|||||||
self.log = logging.getLogger('gertty.App')
|
self.log = logging.getLogger('gertty.App')
|
||||||
self.log.debug("Starting")
|
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.project_cache = ProjectCache()
|
||||||
self.ring = mywid.KillRing()
|
self.ring = mywid.KillRing()
|
||||||
self.input_buffer = []
|
self.input_buffer = []
|
||||||
|
@ -186,6 +186,8 @@ class Config(object):
|
|||||||
self.socket_path = os.path.expanduser(socket_path)
|
self.socket_path = os.path.expanduser(socket_path)
|
||||||
log_file = server.get('log-file', '~/.gertty.log')
|
log_file = server.get('log-file', '~/.gertty.log')
|
||||||
self.log_file = os.path.expanduser(log_file)
|
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({}),
|
self.palettes = {'default': gertty.palette.Palette({}),
|
||||||
'light': gertty.palette.Palette(gertty.palette.LIGHT_PALETTE),
|
'light': gertty.palette.Palette(gertty.palette.LIGHT_PALETTE),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user