Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(840)

Side by Side Diff: remoting/host/linux/linux_me2me_host.py

Issue 254393003: Add systemwide session file for Chromoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop support for ~/.[xX]session Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Virtual Me2Me implementation. This script runs and manages the processes 6 # Virtual Me2Me implementation. This script runs and manages the processes
7 # required for a Virtual Me2Me desktop, which are: X server, X desktop 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop
8 # session, and Host process. 8 # session, and Host process.
9 # This script is intended to run continuously as a background daemon 9 # This script is intended to run continuously as a background daemon
10 # process, running under an ordinary (non-root) user account. 10 # process, running under an ordinary (non-root) user account.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if IS_INSTALLED: 49 if IS_INSTALLED:
50 HOST_BINARY_NAME = "chrome-remote-desktop-host" 50 HOST_BINARY_NAME = "chrome-remote-desktop-host"
51 else: 51 else:
52 HOST_BINARY_NAME = "remoting_me2me_host" 52 HOST_BINARY_NAME = "remoting_me2me_host"
53 53
54 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop" 54 CHROME_REMOTING_GROUP_NAME = "chrome-remote-desktop"
55 55
56 HOME_DIR = os.environ["HOME"] 56 HOME_DIR = os.environ["HOME"]
57 CONFIG_DIR = os.path.join(HOME_DIR, ".config/chrome-remote-desktop") 57 CONFIG_DIR = os.path.join(HOME_DIR, ".config/chrome-remote-desktop")
58 SESSION_FILE_PATH = os.path.join(HOME_DIR, ".chrome-remote-desktop-session") 58 SESSION_FILE_PATH = os.path.join(HOME_DIR, ".chrome-remote-desktop-session")
59 SYSTEM_SESSION_FILE_PATH = "/etc/chrome-remote-desktop-session"
59 60
60 X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock" 61 X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock"
61 FIRST_X_DISPLAY_NUMBER = 20 62 FIRST_X_DISPLAY_NUMBER = 20
62 63
63 # Amount of time to wait between relaunching processes. 64 # Amount of time to wait between relaunching processes.
64 SHORT_BACKOFF_TIME = 5 65 SHORT_BACKOFF_TIME = 5
65 LONG_BACKOFF_TIME = 60 66 LONG_BACKOFF_TIME = 60
66 67
67 # How long a process must run in order not to be counted against the restart 68 # How long a process must run in order not to be counted against the restart
68 # thresholds. 69 # thresholds.
69 MINIMUM_PROCESS_LIFETIME = 60 70 MINIMUM_PROCESS_LIFETIME = 60
70 71
71 # Thresholds for switching from fast- to slow-restart and for giving up 72 # Thresholds for switching from fast- to slow-restart and for giving up
72 # trying to restart entirely. 73 # trying to restart entirely.
73 SHORT_BACKOFF_THRESHOLD = 5 74 SHORT_BACKOFF_THRESHOLD = 5
74 MAX_LAUNCH_FAILURES = SHORT_BACKOFF_THRESHOLD + 10 75 MAX_LAUNCH_FAILURES = SHORT_BACKOFF_THRESHOLD + 10
75 76
76 # Globals needed by the atexit cleanup() handler. 77 # Globals needed by the atexit cleanup() handler.
77 g_desktops = [] 78 g_desktops = []
78 g_host_hash = hashlib.md5(socket.gethostname()).hexdigest() 79 g_host_hash = hashlib.md5(socket.gethostname()).hexdigest()
79 80
80 def is_supported_platform(): 81 def is_supported_platform():
81 # Always assume that the system is supported if the config directory or 82 # Always assume that the system is supported if the config directory or
82 # session file exist. 83 # session file exist.
83 if os.path.isdir(CONFIG_DIR) or os.path.isfile(SESSION_FILE_PATH): 84 if os.path.isdir(CONFIG_DIR) or os.path.isfile(SESSION_FILE_PATH):
Sergey Ulanov 2014/04/26 00:36:31 maybe add a check for SYSTEM_SESSION_FILE_PATH her
Lambros 2014/04/28 18:47:58 Done.
84 return True 85 return True
85 86
86 # The host has been tested only on Ubuntu. 87 # The host has been tested only on Ubuntu.
87 distribution = platform.linux_distribution() 88 distribution = platform.linux_distribution()
88 return (distribution[0]).lower() == 'ubuntu' 89 return (distribution[0]).lower() == 'ubuntu'
89 90
90 class Config: 91 class Config:
91 def __init__(self, path): 92 def __init__(self, path):
92 self.path = path 93 self.path = path
93 self.data = {} 94 self.data = {}
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 524
524 def choose_x_session(): 525 def choose_x_session():
525 """Chooses the most appropriate X session command for this system. 526 """Chooses the most appropriate X session command for this system.
526 527
527 Returns: 528 Returns:
528 A string containing the command to run, or a list of strings containing 529 A string containing the command to run, or a list of strings containing
529 the executable program and its arguments, which is suitable for passing as 530 the executable program and its arguments, which is suitable for passing as
530 the first parameter of subprocess.Popen(). If a suitable session cannot 531 the first parameter of subprocess.Popen(). If a suitable session cannot
531 be found, returns None. 532 be found, returns None.
532 """ 533 """
533 # If the session wrapper script (see below) is given a specific session as an
534 # argument (such as ubuntu-2d on Ubuntu 12.04), the wrapper will run that
535 # session instead of looking for custom .xsession files in the home directory.
Lambros 2014/04/24 20:27:52 Don't think this comment makes much sense any more
536 # So it's necessary to test for these files here.
537 XSESSION_FILES = [ 534 XSESSION_FILES = [
538 SESSION_FILE_PATH, 535 SESSION_FILE_PATH,
539 "~/.xsession", 536 SYSTEM_SESSION_FILE_PATH ]
540 "~/.Xsession" ]
541 for startup_file in XSESSION_FILES: 537 for startup_file in XSESSION_FILES:
542 startup_file = os.path.expanduser(startup_file) 538 startup_file = os.path.expanduser(startup_file)
543 if os.path.exists(startup_file): 539 if os.path.exists(startup_file):
544 # Use the same logic that a Debian system typically uses with ~/.xsession 540 # Use the same logic that a Debian system typically uses with ~/.xsession
545 # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine 541 # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine
546 # exactly how to run this file. 542 # exactly how to run this file.
547 if os.access(startup_file, os.X_OK): 543 if os.access(startup_file, os.X_OK):
548 # "/bin/sh -c" is smart about how to execute the session script and 544 # "/bin/sh -c" is smart about how to execute the session script and
549 # works in cases where plain exec() fails (for example, if the file is 545 # works in cases where plain exec() fails (for example, if the file is
550 # marked executable, but is a plain script with no shebang line). 546 # marked executable, but is a plain script with no shebang line).
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 else: 1206 else:
1211 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1207 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1212 elif os.WIFSIGNALED(status): 1208 elif os.WIFSIGNALED(status):
1213 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1209 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1214 1210
1215 1211
1216 if __name__ == "__main__": 1212 if __name__ == "__main__":
1217 logging.basicConfig(level=logging.DEBUG, 1213 logging.basicConfig(level=logging.DEBUG,
1218 format="%(asctime)s:%(levelname)s:%(message)s") 1214 format="%(asctime)s:%(levelname)s:%(message)s")
1219 sys.exit(main()) 1215 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698