summaryrefslogtreecommitdiff
blob: 37c2ce2361f3233f7f7ce9645ccceac8b98f737c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Author: Matthew Ogilvie
Date:   Sat Jan 17 09:24:34 2015 -0700

    add some suggestions to the missing-directory error message
    
    Also wait until directory confirmed before forking.
    
    See gentoo bug 502574 and bug 442874

diff --git a/http-replicator b/http-replicator
index bbc163c..81e254d 100755
--- a/http-replicator
+++ b/http-replicator
@@ -636,13 +636,6 @@ def main ():
 				parser.error('user %r does not exist' % options.user)
 			except OSError:
 				parser.error('no permission for changing to user %r' % options.user)
-		pid = os.fork() # fork process
-		if pid: # parent process
-			pidfile.write(str(pid)) # store child's pid
-			pidfile.close()
-			return
-		else:
-			signal.signal(signal.SIGHUP, signal.SIG_IGN)
 	else:
 		handler = logging.StreamHandler(sys.stdout) # log to stdout
 		handler.setFormatter(logging.Formatter('%(levelname)s: %(name)s %(message)s'))
@@ -651,10 +644,22 @@ def main ():
 	try:
 		os.chdir(options.dir) # change to cache directory
 	except OSError:
-		parser.error('invalid directory %r' % options.dir)
+		parser.error('invalid directory %r\n' \
+		             'Try running repcacheman, and/or see\n' \
+		             'http://forums.gentoo.org/viewtopic-t-173226.html' \
+				 % options.dir)
 	if not os.access(os.curdir, os.R_OK | os.W_OK): # check permissions for cache directory
 		parser.error('no read/write permission for directory %r' % options.dir)
 
+	if options.daemon:
+		pid = os.fork() # fork process
+		if pid: # parent process
+			pidfile.write(str(pid)) # store child's pid
+			pidfile.close()
+			return
+		else:
+			signal.signal(signal.SIGHUP, signal.SIG_IGN)
+
 	sys.stdout = sys.stderr = open('/dev/null', 'w') # redirect all output to bit bucket
 	logging.root.name = 'HttpReplicator'
 	try: