|
51 |
|
51 |
|
52 |
parser = OptionParser() |
52 |
parser = OptionParser() |
53 |
parser.add_option("--configbasename", dest="configbasename", help="", metavar="CONFIGBASENAME", default="connector") |
53 |
parser.add_option("--configbasename", dest="configbasename", help="", metavar="CONFIGBASENAME", default="connector") |
|
|
54 |
parser.add_option('-n', '--no-daemon', dest='daemonize', default=True, action='store_false', help='Start process in foreground') |
54 |
(options, args) = parser.parse_args() |
55 |
(options, args) = parser.parse_args() |
55 |
|
56 |
|
56 |
CONFIGBASENAME = "connector" |
57 |
CONFIGBASENAME = "connector" |
|
64 |
import mapping |
65 |
import mapping |
65 |
|
66 |
|
66 |
|
67 |
|
|
|
68 |
def bind_stdout(): |
69 |
if options.daemonize: |
70 |
sys.stdout = open(STATUSLOGFILE, 'w+') |
71 |
return sys.stdout |
72 |
|
73 |
|
67 |
def daemon(lock_file): |
74 |
def daemon(lock_file): |
68 |
try: |
75 |
try: |
69 |
pid = os.fork() |
76 |
pid = os.fork() |
Lines 107-115
def daemon(lock_file):
|
Link Here
|
---|
|
107 |
|
114 |
|
108 |
|
115 |
|
109 |
def connect(): |
116 |
def connect(): |
110 |
|
117 |
f = bind_stdout() |
111 |
f = open(STATUSLOGFILE, 'w+') |
|
|
112 |
sys.stdout = f |
113 |
print time.ctime() |
118 |
print time.ctime() |
114 |
|
119 |
|
115 |
baseConfig = ConfigRegistry() |
120 |
baseConfig = ConfigRegistry() |
Lines 202-209
def connect():
|
Link Here
|
---|
|
202 |
retry_rejected = 0 |
207 |
retry_rejected = 0 |
203 |
connected = True |
208 |
connected = True |
204 |
while connected: |
209 |
while connected: |
205 |
f = open(STATUSLOGFILE, 'w+') |
210 |
f = bind_stdout() |
206 |
sys.stdout = f |
|
|
207 |
print time.ctime() |
211 |
print time.ctime() |
208 |
# Aenderungen pollen |
212 |
# Aenderungen pollen |
209 |
sys.stdout.flush() |
213 |
sys.stdout.flush() |
Lines 275-281
def main():
|
Link Here
|
---|
|
275 |
print >>sys.stderr, 'Error: Another S4 connector process is already running.' |
279 |
print >>sys.stderr, 'Error: Another S4 connector process is already running.' |
276 |
sys.exit(1) |
280 |
sys.exit(1) |
277 |
|
281 |
|
278 |
daemon(lock_file) |
282 |
if options.daemonize: |
|
|
283 |
daemon(lock_file) |
279 |
|
284 |
|
280 |
while True: |
285 |
while True: |
281 |
try: |
286 |
try: |
Lines 284-291
def main():
|
Link Here
|
---|
|
284 |
lock_file.close() |
289 |
lock_file.close() |
285 |
raise |
290 |
raise |
286 |
except: |
291 |
except: |
287 |
f = open(STATUSLOGFILE, 'w+') |
292 |
f = bind_stdout() |
288 |
sys.stdout = f |
|
|
289 |
print time.ctime() |
293 |
print time.ctime() |
290 |
|
294 |
|
291 |
text = '' |
295 |
text = '' |