TryQuiet / quiet

A private, p2p alternative to Slack and Discord built on Tor & IPFS
https://www.tryquiet.org
GNU General Public License v3.0
1.96k stars 85 forks source link

How do I run the backend without desktop #1922

Open Ahmedouu opened 1 year ago

Ahmedouu commented 1 year ago

in the docs it says there is an entryNode.ts but I can't find it.

thanks,

leblowl commented 1 year ago

Thanks for the issue @Ahmedouu. It looks like the docs are out of date and it doesn't seem like there is an easy way to run them separately anymore without changes to the frontend code since it appears to spawn the backend automatically: https://github.com/TryQuiet/quiet/blob/2de5ba6fb5cd925277922d95d65ef1f42b1a9589/packages/desktop/src/main/main.ts#L355-L373

I'd definitely like to fix this and the docs.

Here is an example of how I was running the backend independently recently:

cd packages/backend
npm run webpack && DEBUG=* node ../backend-bundle/bundle.cjs -d 42241 -a '/home/lucas/.config/Quietdev' -r '/home/lucas/src/tryquiet/quiet/packages/desktop/node_modules/electron/dist/resources' -p desktop
Ahmedouu commented 1 year ago

@leblowl great! meanwhile can you tell me what is in the .config/Quietdev ?

Thanks,

holmesworcester commented 1 year ago

That's the same as .config/Quiet in the built version. It's the default file storage location that .AppImage uses. We use Quietdev so that you can run a dev version of Quiet alongside production Quiet without the two interfering.

Inside there is the Tor configuration files, IPFS and OrbitDB data, and a few other things.

Ahmedouu commented 1 year ago

when I run the backend I don't see libp2p or Tor starting, it always stops here: backend:SocketService Data server running on port 33947 +1ms

When running the desktop there is libva error but it doesn't stop it keeps going until tor

please advise how to go around this or should I just wait for the fix

leblowl commented 1 year ago

@Ahmedouu I think we need to fix this up a bit. I also noticed the backend doesn't seem to initialize everything until it has some interaction from the frontend.

Ahmedouu commented 1 year ago

@leblowl from what I can tell, this promise doesn't get enough time to resolve when running the backend on it's own and the rest of the runBackendDesktop() doesn't execute:

https://github.com/TryQuiet/quiet/blob/f6b1f19083967fb283a2863348453f92db209fb2/packages/backend/src/backendManager.ts#L53C1-L66C4

leblowl commented 11 months ago

@Ahmedouu Interesting, if you have any ideas for fixes, they are always welcome!

Ahmedouu commented 11 months ago

@leblowl thanks for replying, i am not sure yet but I tried using electron instead of the node binary to run the backend process:

npm run webpack && DEBUG=* ../desktop/node_modules/electron/dist/electron ../backend-bundle/bundle.cjs -d 42241 -a '/home/perky/.config/Quietdev' -r '/home/perky/quiet/packages/desktop/node_modules/electron
/dist/resources' -p desktop

//in backendManager.ts 
process.env.ELECTRON_RUN_AS_NODE = '1'; 

unfortunately though I kept running into this error https://github.com/electron/electron/issues/40394, it's worth noting though that there is a warning in the desktop run about a sandboxed_renderer.bundle.js and several others sandbox bundles my guess is that it's related to this.

at the moment i am not sure how to debug this but will keep you updated when i get the chance.

holmesworcester commented 11 months ago

@EmiM or @vinkabuki -- do either of you know how to do this?

We have tests that run backend and state-manager together without Electron, correct? Can you point to an example here?

vinkabuki commented 11 months ago

when I run the backend I don't see libp2p or Tor starting, it always stops here: backend:SocketService Data server running on port 33947 +1ms

When running the desktop there is libva error but it doesn't stop it keeps going until tor

please advise how to go around this or should I just wait for the fix

That's correct what you see, libp2p, ipfs, orbitdb don't start automatically. You must create a community and run launchCommunity with these params, first you must create all of those:

const payload: InitCommunityPayload = { id: identity.id, peerId: identity.peerId, hiddenService: identity.hiddenService, peers: peerList, }

check launchCommunity.saga.ts and connections-manager.service.ts for more info