[ARVADOS] created: 98acd11d6adaf34f0b0ea458085f7427521c9944

git at public.curoverse.com git at public.curoverse.com
Fri Dec 11 14:49:09 EST 2015


        at  98acd11d6adaf34f0b0ea458085f7427521c9944 (commit)


commit 98acd11d6adaf34f0b0ea458085f7427521c9944
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri Dec 11 14:49:01 2015 -0500

    7939: Move daemonize to _run_standalone() after llfuse.init() and preserve open
    /dev/fuse file descriptor.

diff --git a/services/fuse/arvados_fuse/command.py b/services/fuse/arvados_fuse/command.py
index 93bcd20..3fcc0ea 100644
--- a/services/fuse/arvados_fuse/command.py
+++ b/services/fuse/arvados_fuse/command.py
@@ -95,14 +95,6 @@ class Mount(object):
         if self.args.logfile:
             self.args.logfile = os.path.realpath(self.args.logfile)
 
-        # Daemonize as early as possible, so we don't accidentally close
-        # file descriptors we're using.
-        self.daemon_ctx = None
-        if not (self.args.exec_args or self.args.foreground):
-            os.chdir(self.args.mountpoint)
-            self.daemon_ctx = daemon.DaemonContext(working_directory='.')
-            self.daemon_ctx.open()
-
         try:
             self._setup_logging()
             self._setup_api()
@@ -141,8 +133,6 @@ class Mount(object):
         # Configure a log handler based on command-line switches.
         if self.args.logfile:
             log_handler = logging.FileHandler(self.args.logfile)
-        elif self.daemon_ctx:
-            log_handler = logging.NullHandler()
         else:
             log_handler = None
 
@@ -162,6 +152,7 @@ class Mount(object):
             keep_params={
                 "block_cache": arvados.keep.KeepBlockCache(self.args.file_cache)
             })
+        self.api.users().current().execute()
 
     def _setup_mount(self):
         self.operations = Operations(
@@ -326,6 +317,24 @@ From here, the following directories are available:
         try:
             llfuse.init(self.operations, self.args.mountpoint, self._fuse_options())
 
+            if not (self.args.exec_args or self.args.foreground):
+                fuse_fd = None
+                try:
+                    for fds in os.listdir("/proc/self/fd"):
+                        if os.readlink(os.path.join("/proc/self/fd", fds)) == "/dev/fuse":
+                            fuse_fd = [int(fds)]
+                            break
+                except OSError:
+                    pass
+
+                if fuse_fd is None:
+                   fuse_fd = range(3, 999999)
+
+                os.chdir(os.path.dirname(self.args.mountpoint))
+                self.daemon_ctx = daemon.DaemonContext(working_directory='.',
+                                                       files_preserve=fuse_fd)
+                self.daemon_ctx.open()
+
             # Subscribe to change events from API server
             self.operations.listen_for_events()
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list