vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

VSCode Server: Ability to run vscode-server as a daemon in the server and other feedback

Open tvvignesh opened this issue 3 years ago • 8 comments

Hi. I have started using VSCode Server today and I should say its really awesome. One thing I feel is missing is that, the code-server cli could offer users an ability to run code-server as a daemon/background process in the host machine and also auto start on reboot rather than users figuring out how to do it themselves.

This will create a workflow where you just boot the system, open the browser and start coding

Also, I don't see any information on validity of the tunnel in the docs. If a server is started and tunnel is created, is it valid forever till we stop the server? Also, I don't see any docs on whether this would be charged separately when out of preview or is it meant to be free forever?

And, when I want to open up VSCode windows locally, I typically do code . against a folder but when doing that in the browser, the desktop version of VSCode opens up. Is it possible to open browser based VSCode when doing code . or can there be alternative command to just trigger open new VSCode tabs in the browser opening the respective workspace?

In future, it would be great if there was a developer dashboard where I can start/stop/manage VSCode servers against different instances and open VSCode windows directly from there.

Thanks a lot again for making VSCode awesome. I will drop more feedback as I use VSCode server more.

tvvignesh avatar Aug 26 '22 04:08 tvvignesh

Have you tried to create a systemd service for code-server?

GuillaumeASSIER avatar Aug 26 '22 10:08 GuillaumeASSIER

@Sykursen Yup. That works. Just left the feedback for other users. Also, was not sure how long the auth is valid, so added that as well

tvvignesh avatar Aug 26 '22 11:08 tvvignesh

Hello! Thanks for the feedback!

could offer users an ability to run code-server as a daemon/background process

Yes this is a great idea and planned for the upcoming iteration!

Also, I don't see any information on validity of the tunnel in the docs. If a server is started and tunnel is created, is it valid forever till we stop the server?

The tunnel should stay open forever until you close it your your system shuts down

Also, I don't see any docs on whether this would be charged separately when out of preview or is it meant to be free forever?

This is planned to be free

And, when I want to open up VSCode windows locally, I typically do code . against a folder but when doing that in the browser, the desktop version of VSCode opens up. Is it possible to open browser based VSCode when doing code . or can there be alternative command to just trigger open new VSCode tabs in the browser opening the respective workspace?

This is a good feature request as well. Would you mind creating it in the vscode repo?

tanhakabir avatar Aug 26 '22 15:08 tanhakabir

@tanhakabir Sure. Will create an issue and update here

tvvignesh avatar Aug 26 '22 16:08 tvvignesh

@tvvignesh would you mind sharing your systemd unit file for code-server? I am not well versed at systemd so this would save me some time and help me learn. I would appreciate it very much.

jcouball avatar Sep 05 '22 18:09 jcouball

@jcouball Sure. This is what I used. Just remember to replace the user and group name

/usr/local/bin/codeboot.sh

#!/bin/sh
code-server

/etc/systemd/system/code-server.service

[Unit]
After=network.target

[Service]
User=<yourusername>
Group=<yourgroupname>
ExecStart=/usr/local/bin/codeboot.sh

[Install]
WantedBy=default.target

tvvignesh avatar Sep 06 '22 05:09 tvvignesh

I may be in a minority here, but what would the process be to make this a service on Windows machines? I love having it available, but I don't want to keep a powershell window open all the time.

Also, does VS Code Server keep running if my computer goes to sleep or at least to screensaver? I wouldn't imagine that it would remain running if the computer goes to sleep, but I feel like it should/could if it goes to screensaver.

SpyderHunter03 avatar Sep 15 '22 14:09 SpyderHunter03

Making stuff a process on Windows is a pain, though there are some programs to help with it.

We want to have some install-service command to help out with this.

Also, does VS Code Server keep running if my computer goes to sleep or at least to screensaver? I wouldn't imagine that it would remain running if the computer goes to sleep, but I feel like it should/could if it goes to screensaver.

Screensaver, yes. Someone else also suggested preventing sleep while running, which I think is a good idea (though probably not when in service mode): https://github.com/microsoft/vscode-remote-release/issues/7127

connor4312 avatar Sep 15 '22 15:09 connor4312

@jcouball Sure. This is what I used. Just remember to replace the user and group name

/usr/local/bin/codeboot.sh

#!/bin/sh
code-server

/etc/systemd/system/code-server.service

[Unit]
After=network.target

[Service]
User=<yourusername>
Group=<yourgroupname>
ExecStart=/usr/local/bin/codeboot.sh
Restart=on-failure
RestartSec=90s

[Install]
WantedBy=default.target

Did you chmod the .sh file? I can't seem to get it work I've tried a few times and when I check the log I get code-server.service: Failed to locate executable /usr/local/bin/myfile.sh: Permission denied

:fixed chmod +x codeboot.sh

icouldonlygetthisname avatar Nov 03 '22 18:11 icouldonlygetthisname

@tvvignesh I wanted to report back that the systemd service definition you shared worked like a charm. Now vscode is always running -- no exceptions.

jcouball avatar Nov 03 '22 22:11 jcouball

If you are unsure how to proceed, you might be happy to use the following commands:

systemctl start code-server.service
systemctl status code-server.service
systemctl reload code-server.service
systemctl stop code-server.service

vaeng avatar Nov 28 '22 19:11 vaeng

This issue should have been closed with https://github.com/microsoft/vscode/pull/166411 The CLI (which we will release to stable next week) now has subcommands under code tunnel service --help to run as a service, as a launch service on macOS, a user service on Windows, and a systemd unit on Linux. Support for OpenRC for systems like Alpine Linux may be a future addition.

connor4312 avatar Nov 28 '22 20:11 connor4312

@connor4312 Thanks for your info.

I can connect to the tunnel after running code tunnel service install but there is no any system service installed (run systemctl status code-server.service and shows Unit code-server.service could not be found.) and the service will not auto start after rebooting.

Enviroment

  • Running with non root user
Operating System: Ubuntu 22.04.1 LTS              
Kernel: Linux 5.15.0-50-generic
Architecture: x86-64
code -v
1.74.0
5235c6bb189b60b01b1f49062f4ffa42384f8c91
x64

serkodev avatar Dec 10 '22 13:12 serkodev

@connor4312 Thanks for your info.

I can connect to the tunnel after running code tunnel service install but there is no any system service installed (run systemctl status code-server.service and shows Unit code-server.service could not be found.) and the service will not auto start after rebooting.

Enviroment

  • Running with non root user
Operating System: Ubuntu 22.04.1 LTS              
Kernel: Linux 5.15.0-50-generic
Architecture: x86-64
code -v
1.74.0
5235c6bb189b60b01b1f49062f4ffa42384f8c91
x64

I posted a workaround for that look at the open issues 😄 search for code tunnel service. https://github.com/microsoft/vscode-remote-release/issues/7678

icouldonlygetthisname avatar Dec 10 '22 15:12 icouldonlygetthisname

You need to use the --user flag in the systemctl command line, as the service is installed as a user service, not a system service

connor4312 avatar Dec 10 '22 19:12 connor4312

@connor4312 After I run

systemctl --user enable code-tunnel.service

And it shows error

Unit /home/foo/.vscode-cli/code-tunnel.service is added as a dependency to a non-existent unit multi-user.target.

Is there any option to change the [Install] WantedBy with flag or something else?


@icouldonlygetthisname Thanks, i thinks it's the work around but it is cumbersome to edit the service WantedBy in every time setup.

serkodev avatar Dec 11 '22 09:12 serkodev