Commit Graph

9 Commits

Author SHA1 Message Date
Kostia Balytskyi
4629e800fa hgmain: implement a binary entry point for Mercurial
Summary:
This crate compiles in a binary entry-point for Mercurial.
The way the binary works at first:
- dynamically link to the Python's shared library (Linux, Windows) or Python
  Framework (OSX)
- find the location of `hgexe.py` (this is what's currently known as `hg` and
  what serves as a shebang entrypoint on OSX and Linux today)
- call `Py_Main` with `hgexe.py` and the rest of the supplied arguments

A couple of decisions that someone might find controversial:
- all strings are expected to be correctly conversible to/from Rust String
- in particular, this means that we're limiting the command line arguments (and
  therefore the repo file names) to the valid Unicode strings. This is not much
  of a limitation on Windows, but it is on Linux.
- `build.rs` takes linker path hints from the environment, to be supplied by
  the `setup.py` later
- `hgexe.py` is expected to live either alongside the resulting binary or in
  the `libexec` dir, that is a sister to one of the binary's parents.

Reviewed By: quark-zju

Differential Revision: D9218066

fbshipit-source-id: ff6e01d06f118cd6bc1a20fbab6b5d17fe51b531
2018-08-17 10:51:47 -07:00
Jun Wu
cce43b11c1 scmdaemon: use io::Write on osx
Summary:
D9030136 removed the `use` statement and broke OSX build:

```
   Compiling scm_daemon v0.1.0 (file:///.../exec/scm_daemon)
error[E0599]: no method named `write_fmt` found for type `std::fs::File` in the current scope
  --> src/main.rs:62:33
   |
62 |             File::create(path)?.write_fmt(format_args!("{}", std::process::id()))?;
   |                                 ^^^^^^^^^
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
   |
14 | use std::io::Write;
   |
```

Reviewed By: DurhamG, singhsrb

Differential Revision: D9066112

fbshipit-source-id: f685b75c4032e8388529f6cf8a9724426bd15baa
2018-07-30 11:36:51 -07:00
Hugh Harris
1ac21f90b5 Remove unused import from scm_daemon
Summary: `std::io::Write` was imported but not used causing a warning

Differential Revision: D9030136

fbshipit-source-id: 64e8e2f03cd73ecf77113f6edf7d62c2372833ea
2018-07-27 11:34:32 -07:00
Liubov Dmitrieva
e22322c2e5 commit cloud subscriber: skip cloud sync if can't resolve interngraph host
Summary:
this will reduce cloud sync errors and unnecessary cloud sync calls

the daemon triggers cloud sync on service start/restart
it is not always the time when the machine online (and connected to correct network), so we get cloud sync errors

Reviewed By: markbt

Differential Revision: D8692972

fbshipit-source-id: 59033fd4c3e7c30100d82b908442bbf1ebea9322
2018-06-29 12:20:11 -07:00
Liubov Dmitrieva
f14c984f62 scm_daemon fix broken build
Summary:
std::process::id is stable feature but not for old compilers

https://doc.rust-lang.org/std/process/fn.id.html

hopefully we will revert this diff soon

Reviewed By: markbt

Differential Revision: D8332282

fbshipit-source-id: cd6ed573a7bd1294ac666f267b09a2121c386a34
2018-06-08 07:52:01 -07:00
Liubov Dmitrieva
2d82868f9f scm daemon, write pid file (to be used for restart after log rotation)
Summary: write pid file

Reviewed By: markbt

Differential Revision: D8331445

fbshipit-source-id: 47492ffc9cc87a2ef228ce9581873dec6e01e369
2018-06-08 06:31:10 -07:00
Liubov Dmitrieva
ae7ece9cd5 scm daemon: refactoring
Summary:
just refactoring to improve the code quality

the main improvement is that I separated TcpReceiver to a different service,
any other services can register callbacks with TcpReceiver service.

For WorkspaceSubscriberService callbacks are implemented using mpsc channel to notify the main WorkspaceSubscriberService thread and single atomic flag that allows running subscriptions to join.

Another improvement is that I added logic to run cloud sync on the first keep alive after connection errors

Reviewed By: markbt

Differential Revision: D8226109

fbshipit-source-id: 3fe513da9273b28b2262948ecdf620821e7ab313
2018-06-05 07:11:55 -07:00
Liubov Dmitrieva
12796cbac0 code fixes to support Rust < 1.26
Summary: This changes to support Scm Daemon on dev machines

Reviewed By: farnz

Differential Revision: D8139892

fbshipit-source-id: b6df53d6ce6615d24822b739d4d1705e0f572660
2018-05-24 12:19:55 -07:00
Liubov Dmitrieva
39ccc28933 Scm Daemon initial implementation
Summary: Scm Daemon initial implementation that currently just listen to Commit Cloud Live Notifications and trigger `hg cloud sync` on notifications

Reviewed By: markbt

Differential Revision: D8119768

fbshipit-source-id: a0d86624fe4b81b3adc89990640916d3da279b8c
2018-05-24 12:19:55 -07:00