2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
12 * Hack for HipHop: type checker's client code.
14 * This code gets called in various different ways:
15 * - from emacs, where the output is asynchronous
16 * - from vim, where vim is blocked until this code exits
17 * - from arc diff, our linter
18 * - from arc land, our commit hook
19 * - from check trunk, our irc bot which checks the state of trunk
20 * - manually, from the command line
22 * Usage: hh_client [OPTION]... [WWW DIRECTORY] [FILE]...
26 * => waits for server to initialize
27 * => retries upto 3x on error conditions
28 * => output debugging info
30 * => does not wait for server to initialize
31 * => does not retry on error conditions
32 * => should minimize output to single lines
34 * => waits but does not retry too many times?
37 * Use --help or see clientArgs.ml for more options
40 let exit_on_parent_exit () = Parent.exit_on_parent_exit 10 60
43 (* no-op, needed at entry-point for Daemon hookup *)
44 Daemon.check_entry_point
();
45 (* Ignore SIGPIPE since we might get a server hangup and don't care (can
46 * detect and handle better than a signal). Ignore SIGUSR1 since we sometimes
47 * use that for the server to tell us when it's done initializing, but if we
48 * aren't explicitly listening we don't care. *)
49 Sys_utils.set_signal
Sys.sigpipe
Sys.Signal_ignore
;
50 Sys_utils.set_signal
Sys.sigint
(Sys.Signal_handle
(fun _
->
51 raise
Exit_status.(Exit_with Interrupted
)));
52 let command = ClientArgs.parse_args
() in
53 let root = ClientArgs.root command in
54 HackEventLogger.client_init ~
exit_on_parent_exit root;
55 let command_name = function
56 | ClientCommand.CCheck _
-> "Check"
57 | ClientCommand.CStart _
-> "Start"
58 | ClientCommand.CStop _
-> "Stop"
59 | ClientCommand.CRestart _
-> "Restart"
60 | ClientCommand.CBuild _
-> "Build"
61 | ClientCommand.CLsp _
-> "Lsp"
62 | ClientCommand.CDebug _
-> "Debug"
67 | ClientCommand.CCheck check_env
-> ClientCheck.main check_env
68 | ClientCommand.CStart env
-> ClientStart.main env
69 | ClientCommand.CStop env
-> ClientStop.main env
70 | ClientCommand.CRestart env
-> ClientRestart.main env
71 | ClientCommand.CBuild env
-> ClientBuild.main env
72 | ClientCommand.CLsp env
-> ClientLsp.main env
(* never terminates *)
73 | ClientCommand.CDebug env
-> ClientDebug.main env
74 with Exit_status.Exit_with es
->
75 HackEventLogger.client_bad_exit ~
command:(command_name command) es
;
78 Exit_status.exit
exit_status