Using tmux in VS Remote SSH session - visual-studio-code

I am currently starting to work with SNNs on a GPU server. I am working with VS Code Remote-SSH package. Thereby, I'd like to use the tmux package to be able to start multiple processes which don't terminate when I disconnect the terminal from the server.
So far I used the https://cppdev.medium.com/vs-code-and-tmux-intergation-for-reliable-remote-development-e26594e6757a Tutorial. It already helps me that the process, I run doesn't shut down when I close the terminal but I didn't manage to start a second process on the server because each time, I open a new terminal, the already running process appears. What are your thoughts on that?
Thanks

Related

Embedded terminal processes die if I close the IDE, how to have them continue running?

A novice question... but please help.
I often run "stuff" in the VS code terminal, things like local webapps being served on localhost, scheduled process, etc...
Note: I'm on windows
The workflow is something like:
Turn on computer
Open VS Code
Open the integrated terminal in VS Code (using gitbash)
Run bash start.sh where start.sh is a script that starts some "long-running" processes (eg. Airflow, Streamlit apps, etc...)
The problem is:
If I close VS code the processes die
If I reboot the computer the processes don't restart
I have 'a' solution, but I don't like it:
Build these into docker containers and have these managed by the docker deamon
It seems overkill for quick things that I just want to have running.
So, is there a way to have things from the VS Code terminal "survive/restart" a VS Code close/computer reboot?

keep Running Jupyter notebook with VSCode on remote server (SSH) after disconnecting

i'm working with VSCode on remote server via ssh with the jupyter notebook extension.
but when im disconnect from the session the process of the code is stopped.
is there a way to run the notebook from the VSCode with a backgroung process with tools like tmux.
cause i'm far of being a linux expert and i cant figure out how can i run the notebook process with tmux via the VSCode.
thanks a lot in advance.
Simply start a tmux process in the remote terminal start Jupyter in the tmux session. You can go out of the tmux session without closing it.
In VSC you can choose the tmux session as the host.

Can I run scripts when VSCode boots and closes?

I'm developing on a VM and I'd like to automate booting and shutting down the VM whenever I launch VSCode into this project (over ssh).
I got around having to boot the VM by creating a script that launched the VM then VSCode. I use that to launch VSCode instead of the start menu whenever I want to work on this project. However, this solution doesn't work for shutting down the VM when I'm done.
Is there any way to accomplish this? Maybe some project setting that would execute a shutdown script on the VM when I disconnect, or some way I could hook up a script to run on my machine when VSCode closes that would shut down the VM?
Is there any way to avoid the janky startup script? Can I run a script when VSCode launches as well?
According to Visual Studio Code issue #10044 https://github.com/Microsoft/vscode/issues/10044, there is no way to run a script automatically from inside VSCode at startup unless you are willing to write an extension. Even if you are going to write an extension according to the API documentation https://code.visualstudio.com/api/references/activation-events for VSCode, There is no event for when shutdown occurs.
EDIT: Although it is not possible to do this within VScode alone, you could write a wrapper script when starting and exiting to to run the command.

PowerShell open remote GUI session for UIAutomation

I'm currently working on automatic installation of GUI application using library UIAutomation PS Extensions (https://uiautomation.codeplex.com/). It works pretty well in cases, when I run it against existing Windows user session. I run my PS script, it opens a window and I can click on buttons and so on ..
However, problem raises when this library is called from remote machine. I call my script (which should open a GUI window and start controlling it) via PsExec from remote machine. This causes that script is not able to open GUI window on remote machine and starts to produce various exceptions.
As workaround for this, I can make PsExec to connect to specific existing session on remote host, but unfortunatelly this is not stable as I can't guarantee session's existence.
Does enyone know whether it's possible to force PowerShell to open new session (interactive GUI) through which I would be able to call UIAutomation commands?
Thank in advance
Matthew
I'm not clear on whether it's feasible to remotely open a new interactive desktop session in which to run GUI tests that require one. I'd be interested to find out if it's doable, since problems like this frequently come up when folks try to set up CI tests of Windows GUI apps.
Alternatively, I'd propose solving this by configuring the machine where your tests run to log in as a user at boot. Then you can remotely launch your tests as that user, and make use of their open session. That's worked in the past for me when I've run into similar issues.

Running Emacs Remotely between several machines

I use Emacs remotely using X-Server in a Windows client and Linux server. I noticed that I can halt it using ctrl-z and then type fg 1 to get it working again. Is there some way that I could get it to halt on the machine that I am on, and then log into a different machine and start where I left off? When I start a new ssh session, the emacs job isn't associated to my terminal. There must be someway to "steal" it.
Also, maybe there's an Emacs feature that will do basically the same thing. However, I think closing and re-opening all my files and buffers would take quite a while.
Expanding on the idea of using emacsclient, you can look at what what someone did to solve the problem of editing a file from a different machine than where (s)he started running Emacs.
As of Emacs 23, you can run emacsclient in terminal windows using the -nw option.
Other solutions you might want to try are to use:
gnu screen
vnc
For years I used screen to "attach" and "detach" from a virtual terminal that sounds like your usage model. If you have the ability to use graphics... vnc is really great, just do your work in a vnc session and connect to it any machine.
And your last idea is already implemented by the package desktop (which is bundled with Emacs). Take a look at the wiki page for session management, which includes other alternatives to desktop, as well as add-ons for desktop to lazily load files.
You can run emacs as a server, and use emacsclient to connect to it. You can open multiple connections to the same emacs server, via ttys or X11.
When doing this, C-X C-C will close your connection, and leave the server running.
A simple way to do this by invoking emacs as follows. This will connect to the server if one is running, or create one.
emacsclient --alternate-editor="" -c
Sometimes I will be at work and have to run out the door leaving my Emacs session as it was. Later, I will open an Emacs instance to the same machine (usually using remote SSH) and find that I have files open in Emacs. Now the good news. Emacs allows you to "steal" those files using M-x recover-this-file. I recommend one of Trey's solutions if you can plan ahead. If not, you can use this recover file technique to keep progress moving.