Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

2 instances of sshcode (same machine / same remote user) => WebSocket closed #107

Closed
badaz opened this issue May 21, 2019 · 13 comments
Closed

Comments

@badaz
Copy link

badaz commented May 21, 2019

This problem exists with the last version of sshcode (v0.7 I think) that lives in a user local dir on the remote machine.

If you launch sshcode twice from the same local machine and user to the same remote machine and user, the second instance will disconnect the first one. There can be only one instance running on the server. It used to work well with multiple instances when sshcode was running from the /tmp dir, I do not know how to fix it, but it is a problem since I often work on multiple projects on the same server and I do not want to open only one instance containing all my projects since it will slow down search operations, etc. Is it a know problem? Is there any workaround or possible fix?

@teddy-codes
Copy link
Contributor

teddy-codes commented May 21, 2019

I think the intention would be to only have one instance of code-server running on your remote machine. Not sure why you would have multiple instances of code-server open.

As a workaround (which seems like the only way), you could make a user on your remote server for each of your projects. Then, in your .ssh/config file, you could just have the host be the project (different user of course, but not a different hostname). It would look something like this:

Host project-name
    User project-name
    Hostname remote-instance-ip
    IdentityFile path/to/identity/file.pem

I think this is more or less what you would be looking for here.

@badaz
Copy link
Author

badaz commented May 22, 2019

Hi, thanks for the suggestion but it seems a little overkill to create a user by project. I understand that it would be useless to have multiple servers running, but then shouldn't there be a possibility to run multiple clients connected to the same server, only targeting different directories?

By the way, this tool is a life saver for me, so thanks for the effort!

EDIT: I guess it is not that easy since code-server itself needs a directory to serve files from if I understand well. So my question is: how come it was possible to have multiple servers running when it was installed in /tmp and it is not possible anymore?

@teddy-codes
Copy link
Contributor

teddy-codes commented May 22, 2019

/tmp is an fs that is generally cleaned up after system reboot (I am pretty sure that it is also stored in memory). /var/tmp should be the one that is preserved across system restarts. Does the temp directory still work for code-server?

@badaz
Copy link
Author

badaz commented May 23, 2019

I don't know, I do not use code-server directly, I only tried it once before I discovered sshcode which is simpler and runs in a dedicated window. I guess I could start multiple instances of code-server manually but then it is not as convenient as just running sshcode command with a user@host + dirname

@badaz
Copy link
Author

badaz commented May 23, 2019

Ok I forked your project and added a condition in downloadScript() to skip this step entirely if sshcode-server is already running, that way no pkill and a new server is launched. The nice thing to have though would be a single server instance able to open many websocket connections, one per working dir for example, but I have no idea how complex this might be to implement

@teddy-codes
Copy link
Contributor

I added a comment to the commit where you added this because it looks like you should be using: code-server instead of sshcode-server since that is what sshcode depends on.

The multiple web socket connections would have to be implemented within code-server to make this work (since sshcode just creates an ssh tunnel for you).

Can you still try to run the script from the download parse and see if you can run multiple instances of code-server (you should be able to, but I am just not sure what the complications are. It looks like since you are not killing the instance, that you would not be able to change the directories at all and would have to actually ssh into the instance to kill the code-server instance (sounds annoying). Not sure what your thoughts are here.

@badaz
Copy link
Author

badaz commented May 23, 2019

I'm not sure I understand everything that happens, but with my modified version, the previously running instance is not killed, and when I monitor the server processes with htop I can see the creation of a new sshcode-server process (running code-server in the end) every time I run the script from the client

@teddy-codes
Copy link
Contributor

whatever works for you is good stuff.

@teddy-codes
Copy link
Contributor

have you tried code-server running twice on your remote machine without sshcode?

@badaz
Copy link
Author

badaz commented May 23, 2019

Nope, sorry. Do you plan on doing this multi client/workingdir/socket any time in code-server? Or is it just not the intended use? Maybe I could help (not right now though I'm passing exams until july)

@teddy-codes
Copy link
Contributor

I don't work on code-server, but you could open an issue there and I am sure that someone would be able to help.

@badaz
Copy link
Author

badaz commented May 23, 2019

Oh, alright, I assumed you worked on it, i'll go there then thanks

@badaz badaz closed this as completed May 23, 2019
@teddy-codes
Copy link
Contributor

I realized that I was totally wrong. The executable is sshcode-server, but the program used is code-server.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants