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
41 let () = Random.self_init
()
44 (* no-op, needed at entry-point for Daemon hookup *)
45 Daemon.check_entry_point
();
46 (* Ignore SIGPIPE since we might get a server hangup and don't care (can
47 * detect and handle better than a signal). Ignore SIGUSR1 since we sometimes
48 * use that for the server to tell us when it's done initializing, but if we
49 * aren't explicitly listening we don't care. *)
50 Sys_utils.set_signal
Sys.sigpipe
Sys.Signal_ignore
;
51 Sys_utils.set_signal
Sys.sigint
(Sys.Signal_handle
(fun _
->
52 raise
Exit_status.(Exit_with Interrupted
)));
53 let command = ClientArgs.parse_args
() in
54 let root = ClientArgs.root command in
55 HackEventLogger.client_init ~
exit_on_parent_exit root;
56 let command_name = function
57 | ClientCommand.CCheck _
-> "Check"
58 | ClientCommand.CStart _
-> "Start"
59 | ClientCommand.CStop _
-> "Stop"
60 | ClientCommand.CRestart _
-> "Restart"
61 | ClientCommand.CLsp _
-> "Lsp"
62 | ClientCommand.CDebug _
-> "Debug"
67 | ClientCommand.CCheck check_env
->
68 Lwt_main.run
(ClientCheck.main check_env
)
69 | ClientCommand.CStart env
->
70 Lwt_main.run
(ClientStart.main env
)
71 | ClientCommand.CStop env
->
72 Lwt_main.run
(ClientStop.main env
)
73 | ClientCommand.CRestart env
->
74 Lwt_main.run
(ClientRestart.main env
)
75 | ClientCommand.CLsp env
->
76 Lwt_main.run
(ClientLsp.main env
)
77 | ClientCommand.CDebug env
->
78 Lwt_main.run
(ClientDebug.main env
)
79 with Exit_status.Exit_with es
->
80 HackEventLogger.client_bad_exit ~
command:(command_name command) es
;
83 Exit_status.exit
exit_status