Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 # 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 # 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 # session instead of looking for custom .xsession files in the home directory. |
| 536 # So it's necessary to test for these files here. | 537 # So it's necessary to test for these files here. |
| 537 XSESSION_FILES = [ | 538 XSESSION_FILES = [ |
| 538 SESSION_FILE_PATH, | 539 SESSION_FILE_PATH, |
| 539 "~/.xsession", | 540 "~/.xsession", |
| 540 "~/.Xsession" ] | 541 "~/.Xsession", |
| 542 SYSTEM_SESSION_FILE_PATH ] | |
|
Sergey Ulanov
2014/04/23 22:41:52
Maybe put this above .xsession? (it has higher cha
Lambros
2014/04/23 23:04:13
I'd like to get rid of .xsession completely. Moder
Sergey Ulanov
2014/04/24 00:10:21
sgtm
Lambros
2014/04/24 20:27:52
Done.
| |
| 541 for startup_file in XSESSION_FILES: | 543 for startup_file in XSESSION_FILES: |
| 542 startup_file = os.path.expanduser(startup_file) | 544 startup_file = os.path.expanduser(startup_file) |
| 543 if os.path.exists(startup_file): | 545 if os.path.exists(startup_file): |
| 544 # Use the same logic that a Debian system typically uses with ~/.xsession | 546 # Use the same logic that a Debian system typically uses with ~/.xsession |
| 545 # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine | 547 # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine |
| 546 # exactly how to run this file. | 548 # exactly how to run this file. |
| 547 if os.access(startup_file, os.X_OK): | 549 if os.access(startup_file, os.X_OK): |
| 548 # "/bin/sh -c" is smart about how to execute the session script and | 550 # "/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 | 551 # 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). | 552 # marked executable, but is a plain script with no shebang line). |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 else: | 1212 else: |
| 1211 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) | 1213 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) |
| 1212 elif os.WIFSIGNALED(status): | 1214 elif os.WIFSIGNALED(status): |
| 1213 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) | 1215 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) |
| 1214 | 1216 |
| 1215 | 1217 |
| 1216 if __name__ == "__main__": | 1218 if __name__ == "__main__": |
| 1217 logging.basicConfig(level=logging.DEBUG, | 1219 logging.basicConfig(level=logging.DEBUG, |
| 1218 format="%(asctime)s:%(levelname)s:%(message)s") | 1220 format="%(asctime)s:%(levelname)s:%(message)s") |
| 1219 sys.exit(main()) | 1221 sys.exit(main()) |
| OLD | NEW |