mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
93ad242d60
Summary: In order to start EdenFS automatically at boot, a template service was used previously, but due to several issues, we decided to move away from it. Thankfully microsoft supports several other ways of starting tasks at startup, one of which is the "Task Scheduler" itself. One of the weird part of the task scheduler is that there isn't a good way to tell it to not show a console for a non-graphical application, and thus plainly executing edenfsctl start in it would create a cmd window, which would then disappear a couple of seconds later. To avoid this, a "graphical" version of Python is used (pythonw.exe) to start edenfsctl. Reviewed By: fanzeyi Differential Revision: D21732281 fbshipit-source-id: 87ef3a2d5569302392bd30a4b9e7fc48807ee316
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# pyre-strict
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import List, Optional
|
|
|
|
from . import proc_utils_win
|
|
from .config import EdenInstance
|
|
|
|
|
|
def start_edenfs_service(cmd: List[str]) -> int:
|
|
cmdline = subprocess.list2cmdline(cmd)
|
|
proc_utils_win.create_process_shim(cmdline)
|
|
return 0
|
|
|
|
|
|
def run_edenfs_foreground(cmd: List[str]) -> int:
|
|
"""Run EdenFS in the "foreground" of the user's terminal. It will log directly to
|
|
our stdout/stderr, and we'll wait for it to exit before we return.
|
|
"""
|
|
process = subprocess.Popen(cmd)
|
|
while True:
|
|
try:
|
|
return process.wait()
|
|
except KeyboardInterrupt:
|
|
# Catch the exception if the user interrupts EdenFS with Ctrl-C.
|
|
# The interrupt will have also been delivered to EdenFS, so it should shut
|
|
# down. Continue around the while loop to keep waiting for it to exit, and
|
|
# still pass through its return code.
|
|
continue
|