Commit Graph

113 Commits

Author SHA1 Message Date
Lorenzo Blasa
6e97e73cf1 Better shutdown
Summary: ^

Reviewed By: ivanmisuno

Differential Revision: D49593599

fbshipit-source-id: 196e98653cc0cdda4fdf11e366e5d3ab5debe6e2
2023-09-25 09:59:24 -07:00
Lorenzo Blasa
bdf5065f10 Expose info endpoint
Summary:
Expose an endpoint to retrieve server environment information.

We can use version information and process number to aid engineers with troubleshooting Flipper.

Reviewed By: antonk52

Differential Revision: D49537325

fbshipit-source-id: 511fe4441638f91cd35f13706ceeeb515051416b
2023-09-22 08:17:48 -07:00
Lorenzo Blasa
b856180530 Use HTTP shutdown instead
Summary: Use the newly exposed HTTP shutdown API. It is simpler.

Reviewed By: antonk52

Differential Revision: D49499264

fbshipit-source-id: 2d81db1d1a66c0b7550ee1245e51d8f1a8671aa6
2023-09-21 06:59:22 -07:00
Lorenzo Blasa
8062e2c9e5 Generate auth token
Summary: Generate auth token on whenever we load the secure server config,  and add more logs.

Reviewed By: antonk52

Differential Revision: D49272857

fbshipit-source-id: 1e549a8bfd7926e9a44b9480432e92ee3c0162b2
2023-09-14 07:04:59 -07:00
Lorenzo Blasa
2b4c631652 Certificate and token generation fixes
Summary:
A few things need to be done which are on this change:

- Certificate generation should execute as an atomic operation, hence, it needs to be synchronised.
- Do not generate client token as part of certificate generation. This causes a deadlock now.
- Add more logs for troubleshooting

Reviewed By: aigoncharov

Differential Revision: D49269624

fbshipit-source-id: 071a8e5b895198730b7d914cc4622837e9094e2f
2023-09-14 04:15:18 -07:00
Lorenzo Blasa
cf599f9c3c Move launch further down, temporarily
Summary: Attempt to fix an ongoing issue whereas there's a race condition generating certificates

Reviewed By: passy

Differential Revision: D49237915

fbshipit-source-id: 2383b20cb6ba786166d5e70206b5fff846ed1211
2023-09-13 11:52:46 -07:00
Lorenzo Blasa
3292945887 Launch should be blocking and at a later stage
Summary: This should be a blocking call and done later as it depends on the FlipperServerConfig to be set.

Reviewed By: antonk52

Differential Revision: D49193650

fbshipit-source-id: 4f74ca5de30b7f992880bbb9032792fd713203b7
2023-09-13 04:06:58 -07:00
Lorenzo Blasa
dd6cef66f6 Do not log token
Summary: Don't log it, otherwise it may end up in Scuba, we don't want that.

Reviewed By: antonk52

Differential Revision: D49187133

fbshipit-source-id: 38d4ea0801a9abbc463c23340e23f8b55e0d22f3
2023-09-13 04:06:58 -07:00
Pascal Hartig
cd392929e0 FLIPPER_DISABLE_KEYTAR env var to use in-memory impl
Summary: Changelog: FLIPPER_DISABLE_KEYTAR env var can be used to force in-memory implementation

Reviewed By: lblasa

Differential Revision: D49183501

fbshipit-source-id: 4ce886303678485673750417b09f272dd3f66623
2023-09-12 04:21:41 -07:00
Lorenzo Blasa
3bfe9a1f98 Remove not needed 'then' clause
Summary: ^

Reviewed By: antonk52

Differential Revision: D48826887

fbshipit-source-id: 3ecc77d326bd7ddfa5e9f125012d6854f1692010
2023-08-30 06:47:48 -07:00
Lorenzo Blasa
2858259497 Launch early, even if not ready
Summary:
Flipper Launcher downloads, unpacks, launches Flipper, and closes itself.

This is fine except for the fact that Flipper may be initiating and thus there's a gap of a few seconds until engineers see the main Flipper UI.

This change improves this by launching earlier, even if just showing a loading page until Flipper is actually ready.

Reviewed By: passy, aigoncharov

Differential Revision: D48824479

fbshipit-source-id: aa6147a09f313d80592c9b08d089660ba73773a4
2023-08-30 05:08:26 -07:00
Pascal Hartig
554d2f9b83 Bump ES level to 2021
Summary: Updating the remaining tsconfigs to build for an ES2021 target.

Reviewed By: antonk52

Differential Revision: D48687661

fbshipit-source-id: 2761704d251f701594ca5d362a17731f287088ed
2023-08-29 05:06:18 -07:00
Lorenzo Blasa
6405a7bfdd Hook with FB logger
Summary:
This change replaces the existing logging infra with the one defined and exposed in flipper-server-core.

Functionality remains the same with the addition of having support for Scribe.

Reviewed By: aigoncharov

Differential Revision: D48515246

fbshipit-source-id: 7970f6ad069821ee4f15136adc8da40d0b1fb0c7
2023-08-24 06:18:39 -07:00
Pascal Hartig
160b05a5bd Bump deps
Summary:
This updates minor and patch level dependencies. Frustratingly, I had to revert a bunch
of changes in that version range that still caused incompatibilities and test failures.

If I find time, I'll dig a bit deeper.

Reviewed By: ivanmisuno

Differential Revision: D48433210

fbshipit-source-id: 9ab12e774c1992d4f22cc1428d34f102ce820b75
2023-08-21 03:03:30 -07:00
Lorenzo Blasa
7f3f1c0507 TCP is the only option so remove unused branches
Summary: As TCP is the only option, remove all branches.

Reviewed By: passy

Differential Revision: D48265093

fbshipit-source-id: 174527f05d8a841797fd95256e77fdeb9b2e6ad5
2023-08-11 08:19:51 -07:00
Lorenzo Blasa
47b718d104 Remove TCP option as it will be the only option
Summary: UDS will be removed. The first step would be to remove the TCP optionality.

Reviewed By: passy

Differential Revision: D48264741

fbshipit-source-id: ca9e1b68be61e99240e95bcd4f26f2db63a64005
2023-08-11 08:19:51 -07:00
Lorenzo Blasa
411695484e Open in Chrome instead of default browser
Summary: To avoid the cases whereas Flipper opens up in engineer's default browser which may be different than Chrome.

Reviewed By: aigoncharov

Differential Revision: D46682220

fbshipit-source-id: 38d0ddefbc67989c5ec97a66e4a419318a66bc95
2023-06-13 05:36:23 -07:00
Lorenzo Blasa
0db4e99aff Track bootstrap diagnostics
Summary:
^

In addition to logging to the console bootstrap performance metrics, track these events to scuba as well.

Reviewed By: aigoncharov

Differential Revision: D46648876

fbshipit-source-id: 191704c13158884bb8cfbca614a23f2a64f1fd93
2023-06-13 02:45:57 -07:00
Lorenzo Blasa
b34d3e0a74 Bootstrap logging and performance improvement
Summary:
Add a few console logs as to highlight how long does it take for our server to start.

Additionally, do not wait until we are ready for client connections before attempting to launch. There's nothing else we do at this point. Instead, launch and wait until we are ready.

Reviewed By: passy

Differential Revision: D46639482

fbshipit-source-id: c098d229edc3cd52e5c876c509a7c81532635afa
2023-06-12 04:51:24 -07:00
Lorenzo Blasa
b29ced9d52 Refactor open functionality into function
Summary: ^

Reviewed By: passy

Differential Revision: D46557867

fbshipit-source-id: b741288d38c96288b41d201ac9c229176b9eb197
2023-06-08 11:03:44 -07:00
Lorenzo Blasa
c347fae7c1 Use getAuthToken utility function instead
Summary: ^

Reviewed By: mweststrate

Differential Revision: D46557801

fbshipit-source-id: 2a83613afd9482ff4ed0abe5aaaf9675ef73bc49
2023-06-08 07:17:12 -07:00
Lorenzo Blasa
132a20d5a7 Token read from invalid path
Summary:
^

Token is no longer in the static directory. Also, we can now use a shared utility.

Reviewed By: aigoncharov

Differential Revision: D46516296

fbshipit-source-id: c38d024061653ac8b3fb587c8e3ad83dba0b151d
2023-06-07 07:39:56 -07:00
Lorenzo Blasa
bb9793019c Expand PATH with /usr/local/bin
Summary:
^

There is an issue whereas when Flipper Server is launched NOT from the terminal, it doesn't inherit the user's terminal `$PATH` variable.

This causes a few different issues.

This change tries to address that.

Reviewed By: passy

Differential Revision: D46392435

fbshipit-source-id: 6201a1749134db8c50eca8751af149737dce57d7
2023-06-02 08:01:51 -07:00
Lorenzo Blasa
6430403da0 Jest update v26.6.3 -> v29.5.1
Summary:
^

Basically, update Jest and fix any raised issues. Mainly:
- Update necessary dependencies
- Update snapshots
- `useFakeTimers` caused a few issues which meant that the way we hook into the performance object had to be tweaked. The main code change is: `//fbsource/xplat/sonar/desktop/scripts/jest-setup-after.tsx`
- `mocked` -> `jest.mocked`

Changelog: Update Jest to v29.5.1

Reviewed By: antonk52

Differential Revision: D46319818

fbshipit-source-id: d218ca8f7e43abac6b00844953ddeb7f4e1010a2
2023-05-31 14:19:29 -07:00
Lorenzo Blasa
76fbaf245c Replace existing running instance, if any
Summary:
Replace an existing running instance, if any.

This is useful for:
- Applying updates
- Ensuring freshness of server

Reviewed By: passy

Differential Revision: D46146814

fbshipit-source-id: bfb760f3ab26b7632510773609f1c6ca3a97c4ec
2023-05-25 06:32:18 -07:00
Lorenzo Blasa
4704c177ec Check if server is already listening
Summary:
Right now, this simply avoids trying to create a server instance if one appears to be already running.

In a future change, we may decide to kill the existing instance and replace it with a new one.

But, in this case, running this as is will be useful as it will provide the connection URL with the auth token.

Also remove flipper server dependency from finding installation. In this case, we don't need it and can use `os.getPlatform()` instead.

Reviewed By: antonk52

Differential Revision: D46144843

fbshipit-source-id: 2922843b916d37e0126e43ae65a622f87a6920ec
2023-05-24 06:50:05 -07:00
Lorenzo Blasa
c6d5eb3334 Flipper as PWA
Summary:
^

Reference: https://docs.google.com/document/d/1flQJUzTe4AuQz3QCpvbloQycenHsu7ZxbKScov7K7ao

Reviewed By: passy

Differential Revision: D45693382

fbshipit-source-id: 5a2e6c213a7e7e2cf9cd5f3033cff3e5291a2a92
2023-05-16 04:32:47 -07:00
Lorenzo Blasa
a96caacb2b EnvironmentInfo as argument to start server
Summary:
Clean initialisation by passing down the environment info to start server.

(Also rename dir to path as that's the name used in other places)

Reviewed By: passy

Differential Revision: D45731751

fbshipit-source-id: a60fdd49c567fc312d1f8da72db3a46a0828c140
2023-05-11 04:10:16 -07:00
Lorenzo Blasa
b94f6b6152 Set the right environment info for headless builds
Summary: The isHeadlessBuild flag was not properly set.

Reviewed By: antonk52

Differential Revision: D45728435

fbshipit-source-id: 3616c4358114d4f3d96372766dabf48b27b44333
2023-05-10 04:35:17 -07:00
Lorenzo Blasa
238f40f55d Mandate auth token to connect over TCP
Summary:
Until now, launching flipper-server with TCP would accept any incoming connection as long as it comes from the same origin (localhost) using web socket host origin verification.

This is not entirely secure as origin can be spoofed with tools like curl.

Our team created a security review and a proposal was written:
https://docs.google.com/document/d/16iXypCQibPiner061SoaQUFUY9tLVAEpkKfV_hUXI7c/

Effectively, Flipper can generate a token which is then used by the client to authenticate.

This diff contains the changes required to generate, obtain, and validate authentication tokens from clients connecting to flipper over TCP connections.

The token itself is a JWT token. JWT was chosen because it is a simple industry standard which offers three features which can immediately benefit us:

- Expiration handling. No need for Flipper to store this information anywhere.
- Payload. Payload can be used to push any data we deem relevant i.e. unix username.
- Signing. Signed and verified using the same server key pair which is already in place for certificate exchange.

Additionally, the token is stored in the Flipper static folder. This ensures that the browser and PWA clients have access to it.

Reviewed By: mweststrate

Differential Revision: D45179654

fbshipit-source-id: 6761bcb24f4ba30b67d1511cde8fe875158d78af
2023-05-05 07:52:13 -07:00
Pascal Hartig
18b6ce6f24 Dep bump
Summary: Combining a bunch of individual tasks for dep upgrades into one diff.

Reviewed By: ivanmisuno

Differential Revision: D42706074

fbshipit-source-id: 054b2545ad1295699f47f4c6eb5065b7b9a1d6a0
2023-01-25 04:35:09 -08:00
dependabot[bot]
404449d499 Bump yargs from 17.4.1 to 17.6.0 in /desktop (#4165)
Summary:
Bumps [yargs](https://github.com/yargs/yargs) from 17.4.1 to 17.6.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs/blob/main/CHANGELOG.md">yargs's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/yargs/yargs/compare/v17.5.1...v17.6.0">17.6.0</a> (2022-10-01)</h2>
<h3>Features</h3>
<ul>
<li><strong>lang:</strong> Czech locale (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2220">https://github.com/facebook/flipper/issues/2220</a>) (<a href="5895cf1ba1">5895cf1</a>)</li>
<li><strong>usage:</strong> add YARGS_DISABLE_WRAP env variable to disable wrap (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2210">https://github.com/facebook/flipper/issues/2210</a>) (<a href="b680ace299">b680ace</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deno:</strong> use 'globalThis' instead of 'window' (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2186">https://github.com/facebook/flipper/issues/2186</a>) (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2215">https://github.com/facebook/flipper/issues/2215</a>) (<a href="561fc7a787">561fc7a</a>)</li>
<li><strong>deps:</strong> cliui with forced strip-ansi update (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2241">https://github.com/facebook/flipper/issues/2241</a>) (<a href="38e8df10f0">38e8df1</a>)</li>
<li>dont clobber description for multiple option calls (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2171">https://github.com/facebook/flipper/issues/2171</a>) (<a href="f91d9b334a">f91d9b3</a>)</li>
<li><strong>typescript:</strong> address warning with objectKeys (<a href="394f5f86d1">394f5f8</a>)</li>
</ul>
<h3><a href="https://github.com/yargs/yargs/compare/v17.5.0...v17.5.1">17.5.1</a> (2022-05-16)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>add missing entries to published files (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2185">https://github.com/facebook/flipper/issues/2185</a>) (<a href="5685382d18">5685382</a>)</li>
<li>address bug when strict and async middleware used together (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2164">https://github.com/facebook/flipper/issues/2164</a>) (<a href="cbc2eb726e">cbc2eb7</a>)</li>
<li><strong>completion:</strong> correct zsh installation instructions (<a href="22e9af28bb">22e9af2</a>)</li>
<li>handle multiple node_modules folders determining mainFilename for ESM (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2123">https://github.com/facebook/flipper/issues/2123</a>) (<a href="e0823dd7e6">e0823dd</a>)</li>
<li><strong>lang:</strong> add missing terms to Russian translation (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2181">https://github.com/facebook/flipper/issues/2181</a>) (<a href="1c331f22c7">1c331f2</a>)</li>
<li>prevent infinite loop with empty locale (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2179">https://github.com/facebook/flipper/issues/2179</a>) (<a href="b672e709e4">b672e70</a>)</li>
<li>veriadic arguments override array provided in config (the same as multiple dash arguments). (<a href="4dac5b8c2f">4dac5b8</a>)</li>
</ul>
<h2><a href="https://github.com/yargs/yargs/compare/v17.4.1...v17.5.0">17.5.0</a> (2022-05-11)</h2>
<h3>Features</h3>
<ul>
<li>add browser.d.ts and check for existence of Error.captureStackTrace() (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2144">https://github.com/facebook/flipper/issues/2144</a>) (<a href="6192990509">6192990</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>completion:</strong> support for default flags (<a href="db35423270">db35423</a>)</li>
<li>import yargs/yargs in esm projects (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2151">https://github.com/facebook/flipper/issues/2151</a>) (<a href="95aed1c175">95aed1c</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="6cd8e2d6a4"><code>6cd8e2d</code></a> chore(main): release 17.6.0 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2213">https://github.com/facebook/flipper/issues/2213</a>)</li>
<li><a href="38e8df10f0"><code>38e8df1</code></a> fix(deps): cliui with forced strip-ansi update (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2241">https://github.com/facebook/flipper/issues/2241</a>)</li>
<li><a href="394f5f86d1"><code>394f5f8</code></a> fix(typescript): address warning with objectKeys</li>
<li><a href="561fc7a787"><code>561fc7a</code></a> fix(deno): use 'globalThis' instead of 'window' (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2186">https://github.com/facebook/flipper/issues/2186</a>) (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2215">https://github.com/facebook/flipper/issues/2215</a>)</li>
<li><a href="5895cf1ba1"><code>5895cf1</code></a> feat(lang): Czech locale (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2220">https://github.com/facebook/flipper/issues/2220</a>)</li>
<li><a href="f91d9b334a"><code>f91d9b3</code></a> fix: dont clobber description for multiple option calls (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2171">https://github.com/facebook/flipper/issues/2171</a>)</li>
<li><a href="b680ace299"><code>b680ace</code></a> feat(usage): add YARGS_DISABLE_WRAP env variable to disable wrap (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2210">https://github.com/facebook/flipper/issues/2210</a>)</li>
<li><a href="659dbbb4a4"><code>659dbbb</code></a> docs: update links to main branch</li>
<li><a href="02515116f8"><code>0251511</code></a> chore(main): release 17.5.1 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2187">https://github.com/facebook/flipper/issues/2187</a>)</li>
<li><a href="22e9af28bb"><code>22e9af2</code></a> fix(completion): correct zsh installation instructions</li>
<li>Additional commits viewable in <a href="https://github.com/yargs/yargs/compare/v17.4.1...v17.6.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=yargs&package-manager=npm_and_yarn&previous-version=17.4.1&new-version=17.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

Pull Request resolved: https://github.com/facebook/flipper/pull/4165

Reviewed By: aigoncharov

Differential Revision: D40022361

Pulled By: aigoncharov

fbshipit-source-id: 5408257376334746865b27b27461ec29dea8e78a
2022-10-05 02:27:07 -07:00
Andrey Goncharov
dd7ba2d6fc Fix fb-stubs replacement for plugin bundling
Reviewed By: nikoant

Differential Revision: D39765543

fbshipit-source-id: 14cbf8a9bdf35031e636bbbde3dbc955faedb66b
2022-09-23 05:50:28 -07:00
Andrey Goncharov
fd811db12b Rebuild all plugins if a shared lib changed
Summary: Some plugins import from shared directories. These directories are not plugins themselves, therefore the current plugin root searching mechanism does nto work for them. To support plugin reloading for this scenario, we start re-building all plugins if we fail to find a plugin root.

Reviewed By: lblasa

Differential Revision: D39693820

fbshipit-source-id: 33dd7de4121bd5665a39b0ea96adce4603dc7df0
2022-09-22 04:17:24 -07:00
Andrey Goncharov
8dc5f4d3ea Remove stale build options
Summary: Now that we build all plugins at all times and it is super-fast, these options are redundant

Reviewed By: lblasa

Differential Revision: D39542723

fbshipit-source-id: 1b30ba384267ec4fd0c35b4dc14f0223ffe414c9
2022-09-15 10:02:19 -07:00
Andrey Goncharov
c69d102ca1 Track plugin changes and notify frontend
Summary: Watch source plugin folders and notify frontend that any of them changed. In subsequent diffs, we will start reloading plugins that changed.

Reviewed By: lblasa

Differential Revision: D39539443

fbshipit-source-id: 726916c0bce336a2c0179558526bcb1b74e35b93
2022-09-15 10:02:19 -07:00
Andrey Goncharov
ed93dfe978 Refine prod and dev deps
Summary: Move flipper local deps to prod deps, so yarn installs them later when we build a bundle

Reviewed By: lblasa

Differential Revision: D39475545

fbshipit-source-id: 5b61d15b45ee315c3b35d8e6836c114b90503b1a
2022-09-15 10:02:19 -07:00
Andrey Goncharov
a67a4e5d0f Remove babel transforms for flipper-server
Summary: Flipper server itself requires no babel transforms. We applied extra transforms only for the bundled plugins. However, we pack and ship all plugins in the /static folder. They are always available on the FS. Therefore we could stop bundling any plugins into flipper-server's source code.

Reviewed By: lblasa

Differential Revision: D38910251

fbshipit-source-id: b3e9fe5ae2ab69ce5579b01b6793ebf7e88baf66
2022-09-15 10:02:19 -07:00
Andrey Goncharov
97b8b8a1c4 Split flipper-plugin package
Summary:
flipper-server-companion depends on flipper-plugin. flipper-plugin includes dependencies that run only in a browser. Splitting flipper-plugin into core and browser packages helps to avoid including browser-only dependencies into flipper-server bundle.
As a result, bundle size could be cut in half. Subsequently, RSS usage drops as there is twice as less code to process for V8.

Note: it currently breaks external flipper-data-source package. It will be restored in subsequent diffs

Reviewed By: lblasa

Differential Revision: D38658285

fbshipit-source-id: 751b11fa9f3a2d938ce166687b8310ba8b059dee
2022-09-15 10:02:19 -07:00
Lorenzo Blasa
583fdd9648 Explicitly close ws in cases of a process exit
Summary:
^

There may be cases whereas the process exits but leaks the socket descriptors.

There's already a hook to close flipper-server.

Reviewed By: passy

Differential Revision: D37550940

fbshipit-source-id: 35004969834bb92bb7cf0f56bda8d7b43c11d6bf
2022-07-01 03:45:44 -07:00
Andrey Goncharov
1052384154 Add log rotating to flipper-server
Summary:
CHANGELOG: Rotate flipper-server logs

Otherwise, they re going to eat up all space eventually in a one monstrous file

Reviewed By: passy

Differential Revision: D37516868

fbshipit-source-id: 478a61c56ec007e4a3d695f7e6df2a61cb33c33a
2022-06-30 07:01:40 -07:00
Lorenzo Blasa
646b9d5a5d UDS/TCP options
Summary:
Provide an option to enable/disable TCP connections on flipper-server.

The only change at this stage is that Flipper Desktop will use UDS to connect to flipper-server.

Reviewed By: passy

Differential Revision: D37519656

fbshipit-source-id: 3d02084666fde532ec76134edf8cf6a231060a48
2022-06-29 15:01:05 -07:00
Andrey Goncharov
13535e9753 Map / route to correct HTML file
Summary: CHANGELOG: Open Flipper Server at /

Reviewed By: lawrencelomax

Differential Revision: D37517406

fbshipit-source-id: 71043c3df75d9436020da477c937795671fa15a9
2022-06-29 07:46:03 -07:00
Andrey Goncharov
dcbc7c40bb Stream server logs to browser
Summary: Makes Flipper Logs tab functional for Flipper Browser

Reviewed By: lblasa

Differential Revision: D37459924

fbshipit-source-id: 4ebf3d47fbbf90bb367e01986b12dec782b03c34
2022-06-28 06:27:43 -07:00
Lorenzo Blasa
ce9feae44f Attach handlers for process errors
Summary:
^
This is an effort to capture and log these errors as to gain visibility when failures occur.

Reviewed By: passy

Differential Revision: D37412861

fbshipit-source-id: 09687a31797aac4c377aa98944ab0701bdf45466
2022-06-24 07:56:42 -07:00
Lorenzo Blasa
335dec1a08 Adds some settings to check flipper-server state
Summary:
There's one setting: to enable or disable flipper-server.

However, I've added some current running state to it. If there's a better way of doing this, please do let me know.

Reviewed By: aigoncharov

Differential Revision: D37276670

fbshipit-source-id: f6c941cf0cfe55c267b9bcb9f799934fba1e28ef
2022-06-22 05:26:11 -07:00
Lorenzo Blasa
8c67b049ab Attach connection handler earlier
Summary:
This change attaches our event handlers as soon as the ws is created.

As a consequence, we need to wait until the server has created any necessary instances required to process incoming requests.

To achieve this, I created a type called `Lazy`.

This type wraps around a value and a promise to that value. Callers can check if the value is set. If not, callers can wait for it.

Ultimately, the value can be set outside of the promise itself.

Reviewed By: passy

Differential Revision: D37284939

fbshipit-source-id: 17dec548d7155a3d65440c9584cec07cbb826c37
2022-06-21 12:48:43 -07:00
Lorenzo Blasa
9cc8e4076f flipper-server refactor
Summary:
This changes moves most of the functionality found in flipper-server to flipper-server-core.

flipper-server will mostly be a package that wraps around flipper-server-core. Staying in flipper-server:
- Command line args
- Orchestration to start the necessary servers

Reviewed By: aigoncharov

Differential Revision: D36807087

fbshipit-source-id: f29002c7cc5d08b8c5184fdaaa02ba22562a9f45
2022-06-07 02:42:16 -07:00
Lorenzo Blasa
ee64216725 Extract logger and write to file
Summary:
This change extracts logging logic out from startFlipperServer.

Logs will also be written to disk.

Reviewed By: passy

Differential Revision: D36473768

fbshipit-source-id: b1df9df79b4aced0d3ba2e8c243aa8d44cf83703
2022-06-01 02:37:03 -07:00
Lorenzo Blasa
2fe7e73175 Refactor checks to see if socket is in use
Summary:
These are utility methods that are not specific to startServer.

They will be reused by other components needing to check if something is listening to a port.

Make socket path is also extracted.

Reviewed By: passy

Differential Revision: D36473641

fbshipit-source-id: 73ed67912052896696b59670cb757d22761eeaa1
2022-05-31 03:31:05 -07:00