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

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: Update is_supported_platform() check Created 6 years, 7 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) or
85 os.path.isfile(SYSTEM_SESSION_FILE_PATH)):
84 return True 86 return True
85 87
86 # The host has been tested only on Ubuntu. 88 # The host has been tested only on Ubuntu.
87 distribution = platform.linux_distribution() 89 distribution = platform.linux_distribution()
88 return (distribution[0]).lower() == 'ubuntu' 90 return (distribution[0]).lower() == 'ubuntu'
89 91
90 class Config: 92 class Config:
91 def __init__(self, path): 93 def __init__(self, path):
92 self.path = path 94 self.path = path
93 self.data = {} 95 self.data = {}
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 525
524 def choose_x_session(): 526 def choose_x_session():
525 """Chooses the most appropriate X session command for this system. 527 """Chooses the most appropriate X session command for this system.
526 528
527 Returns: 529 Returns:
528 A string containing the command to run, or a list of strings containing 530 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 531 the executable program and its arguments, which is suitable for passing as
530 the first parameter of subprocess.Popen(). If a suitable session cannot 532 the first parameter of subprocess.Popen(). If a suitable session cannot
531 be found, returns None. 533 be found, returns None.
532 """ 534 """
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.
536 # So it's necessary to test for these files here.
537 XSESSION_FILES = [ 535 XSESSION_FILES = [
538 SESSION_FILE_PATH, 536 SESSION_FILE_PATH,
539 "~/.xsession", 537 SYSTEM_SESSION_FILE_PATH ]
540 "~/.Xsession" ]
541 for startup_file in XSESSION_FILES: 538 for startup_file in XSESSION_FILES:
542 startup_file = os.path.expanduser(startup_file) 539 startup_file = os.path.expanduser(startup_file)
543 if os.path.exists(startup_file): 540 if os.path.exists(startup_file):
544 # Use the same logic that a Debian system typically uses with ~/.xsession 541 # Use the same logic that a Debian system typically uses with ~/.xsession
545 # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine 542 # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine
546 # exactly how to run this file. 543 # exactly how to run this file.
547 if os.access(startup_file, os.X_OK): 544 if os.access(startup_file, os.X_OK):
548 # "/bin/sh -c" is smart about how to execute the session script and 545 # "/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 546 # 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). 547 # 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: 1207 else:
1211 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1208 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1212 elif os.WIFSIGNALED(status): 1209 elif os.WIFSIGNALED(status):
1213 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1210 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1214 1211
1215 1212
1216 if __name__ == "__main__": 1213 if __name__ == "__main__":
1217 logging.basicConfig(level=logging.DEBUG, 1214 logging.basicConfig(level=logging.DEBUG,
1218 format="%(asctime)s:%(levelname)s:%(message)s") 1215 format="%(asctime)s:%(levelname)s:%(message)s")
1219 sys.exit(main()) 1216 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