Commit Graph

22 Commits

Author SHA1 Message Date
Andrey Goncharov
5693ac7205 Disconnect all mobile clients when all UI clients leave
Summary: Context https://fb.workplace.com/groups/flippersupport/permalink/1730762380737746/

Reviewed By: lblasa

Differential Revision: D51510348

fbshipit-source-id: afafcdd6b89bf1038fec65a7c3e8c2dd9cfd0768
2023-11-22 02:59:27 -08:00
Andrey Goncharov
a400eb2872 Finalize log stream before exiting process
Reviewed By: antonk52

Differential Revision: D51229230

fbshipit-source-id: 0e7f657a170eb8602ade9abf1db1976c5b51dc3f
2023-11-11 08:21:12 -08:00
Andrey Goncharov
6e19c4155c Track session length
Differential Revision: D51172955

fbshipit-source-id: d4f93564a94e232066347c945fa4798033dc0da1
2023-11-09 14:34:52 -08:00
Andrey Goncharov
d54bd7c3ba Refactor browser connection performance tracking
Reviewed By: lblasa

Differential Revision: D51158256

fbshipit-source-id: 17e020dd3c26ac73bf2cf0ceb4c664638c6778e9
2023-11-09 08:25:28 -08:00
Lorenzo Blasa
3993e7461d Shutdown after 5 hours
Summary:
If after 5 hours there are no connected clients, shutdown the server.

This is to prevent cases whereas the long-lived instance makes users use stale versions of Flipper if Flipper stays indefinitely running in the background.

Reviewed By: passy

Differential Revision: D51111926

fbshipit-source-id: 4c38e392cf8a6a4fb840bffdea92c0b0314aefb9
2023-11-08 10:39:18 -08:00
Lorenzo Blasa
640fb86edc Do not shutdown when there's no connected clients
Summary:
^

Also, track client closes with their code and/or error.

Reviewed By: antonk52

Differential Revision: D51110574

fbshipit-source-id: 2416e36256b000664b7677fcf2c03b045d318ed2
2023-11-08 10:39:18 -08:00
Andrey Goncharov
0e664d274a Track browser connections
Reviewed By: lblasa

Differential Revision: D50225630

fbshipit-source-id: 31842fcde494ec05edf2458396d466239397d2c8
2023-10-12 15:16:11 -07:00
Lorenzo Blasa
3c73074e29 Log client disconnect code
Summary: Useful to troubleshoot client disconnections

Reviewed By: antonk52

Differential Revision: D49828632

fbshipit-source-id: 55c7d9e212637cac73bf64e6f3e7516778036015
2023-10-02 08:52:40 -07:00
Lorenzo Blasa
ddf348faa5 Immediately close server if no clients are connected
Summary: ^

Reviewed By: ivanmisuno

Differential Revision: D49539483

fbshipit-source-id: ffbcffe0f0b0f31bc26ba5881b30ae27960c283e
2023-09-22 10:31:15 -07:00
Lorenzo Blasa
4e7a6a70cc Server shutdown only if no errors
Summary:
The socket will close as the endpoint is terminating the connection.

Status code 1000 and 1001 are used for normal closures. Either the connection is no longer needed or the endpoint is going away i.e. browser navigating away from the current page.

WS RFC: https://www.rfc-editor.org/rfc/rfc6455

Reviewed By: LukeDefeo

Differential Revision: D48896696

fbshipit-source-id: 22070ae34b7f35d35589db06108feb718e73e866
2023-09-01 03:25:26 -07:00
Lorenzo Blasa
ef6e3df9df Remove the client from error log
Summary: Removing this information from the error as it will cause duplicated error tasks.

Reviewed By: passy

Differential Revision: D48646678

fbshipit-source-id: 26e5525318b4720568275a5086df00f21b7d2836
2023-08-24 10:05:17 -07:00
Lorenzo Blasa
3f37d29b95 Reintroduce timeout and is production check
Summary:
For dev, let's not kill the server.
Also, reintroduce a timeout of 60 seconds before disconnecting.

Reviewed By: antonk52

Differential Revision: D48432317

fbshipit-source-id: bac6f67101e5be481af06a5ea6ccb3b3134c4075
2023-08-17 13:46:08 -07:00
Lorenzo Blasa
bdc2d5f6eb If there are no connected clients, shutdown immediately
Summary: Instead of delaying the shutdown by a set timer, immediately shutdown.

Reviewed By: antonk52

Differential Revision: D48264571

fbshipit-source-id: 5e6556f2ecafb7cf9a19b3075e72f2be1abf9f95
2023-08-11 08:19:51 -07:00
Andrey Goncharov
3b99e386a2 Fix comment
Reviewed By: LukeDefeo

Differential Revision: D48191671

fbshipit-source-id: 6978e831f48ffe4e8a8c6e71b819205cb3868966
2023-08-09 14:15:33 -07:00
Luke De Feo
eaf5b4c246 Dont kill flipper server when no clients connect and is dev
Summary: This is quite annoying and causes may un needed reboots of flipper server while developing

Reviewed By: antonk52

Differential Revision: D47949842

fbshipit-source-id: c2f18e16a4933e4209e74f51978cb7d05b80ee11
2023-08-01 10:32:29 -07:00
Lorenzo Blasa
8f70cf14a4 Kill server after 30 seconds
Summary: Bring timeout from 15min to 30seconds.

Reviewed By: passy

Differential Revision: D46726959

fbshipit-source-id: cae1fdd4668fc5237ad0f187385f3a63a51c4797
2023-06-14 09:59:21 -07:00
Lorenzo Blasa
85f5c6f893 Close server if no clients are connected
Summary: If after 15min there are no connected clients, close flipper server.

Reviewed By: antonk52

Differential Revision: D46519563

fbshipit-source-id: c3396ed8987be8ca7075c644734793e4ebceba18
2023-06-07 10:46:15 -07:00
Lorenzo Blasa
18854ce5fc Install plugin from marketplace if not available
Summary: For the Flipper Server Companion, if a plugin is being requested which is not yet installed, try to install it first from the marketplace.

Reviewed By: passy

Differential Revision: D37716962

fbshipit-source-id: d618fbc597f82b540dbb02e8ffc296dcee9e1eb9
2022-07-11 07:04:55 -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
Andrey Goncharov
115a4b7997 Use AbstractPluginInitializer from flipper-frontend-core in flipper-ui-core
Summary: See D37139129

Reviewed By: passy

Differential Revision: D37238571

fbshipit-source-id: 39d6bb87d6beacc793ef5acd71097fcc4e82969d
2022-06-20 12:18:40 -07:00
Lorenzo Blasa
8a1e484d0c Handle ws operations in a safe manner
Summary:
After doing some tests, any error thrown during ws events can result in flipper-server shutting down.

To avoid this, effectively, errors throughout should be properly handled.

The problem is that there's no guarantees this is or will be the case.

Instead, wrap the event handlers in a safe function execution wrapper. Any errors will be caught and logged.

Reviewed By: aigoncharov

Differential Revision: D37206923

fbshipit-source-id: 6f7cadc297ac39768030962c6eaadde55048fd21
2022-06-16 10:35:17 -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