I am new to go, delve and GoLand IDE. I would like to remote debug some REST endpoints that are deployed using make and run in a docker (using docker + docker-compose).
The command I use to bring up my environment is make myproject
My endpoints get hosted at: localhost:8080
When creating a debug configuration in GoLand it specifies that before running
dlv debug --headless --listen=:2345 --api-version 2, do the following:
go build -gcflags='-N -l' github.com/myproject
dlv --listen=:2345 --headless=true --api version=2 exec ./myproject
Is there a way for me to attach to my project once it's running on localhost:8080? How will these commands differ if that is the case?
Thanks in advance
This command dlv debug --headless --listen=:2345 --api-version 2 your/package/name allows delve to compile the package then launch itself and the compiled binary.
On the other hand, these commands
go build -gcflags='-N -l' github.com/myproject
dlv --listen=:2345 --headless=true --api version=2 exec ./myproject
show you that you can compile the binary separately, in case you need more flexibility and then launch the debugger. Keep in mind that it's really important to add -gcflags='-N -l' or -gcflags='all=-N -l', depending on which Go version you have, in order for the debugger to be able to have more data available about your application.
As for the:
Is there a way for me to attach to my project once it's running on localhost:8080? How will these commands differ if that is the case?
It depends on where you are running the process. If it's on your machine directly, without a VM or a container, then the IDE has the option in Run|Attach to Process. If the process is running on a different machine then you need to login into that machine and use dlv --headless --listen=:2345 --api-version 2 attach <pid>.
We published an article dedicated to this problem a couple of months ago, please have a look at it for a more detailed reply.
Related
I had been trying to create a context to deploy a few containers from my main Mac to another another but I have been getting a weird error.
So, I have two Macs, one iMac (Late 2013) (here will be called Enterprise) and one Macbook Pro (Mid 2015) (here will be called Defiant). Defiant is my main computer and I want to deploy my container to Enterprise in order to not overload Defiant memory. I have been working with docker context to achieve that. Currently, I have Enterprise running Docker v20.10.16 and Defiant running v20.10.16.
I have created the context on Defiant and after I run the docker context use enterprise and when I run docker container ls I get the following error:
error during connect: Get "http://docker.example.com/v1.24/containers/json": command [ssh -l rafaelguerra -- Enterprise.local docker system dial-stdio] has exited with exit status 127, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=zsh:1: command not found: docker
Does anyone know how to make it work?
Thanks
UPDATE:
Weird thing I just found out, when logged into Enterprise and run echo $PATH returns /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin however when I run ssh rafaelguerra#enterprise.local 'echo $PATH' I got the following /usr/bin:/bin:/usr/sbin:/sbin
I don't have a clue for a reason for this.
I found the reason for the problem, all commands docker run are run within ssh not with a permanent ssh session. So, zsh does not load the correct PATH when the command is run within the ssh. Therefore, the only thing I need to do was setting the correct PATH inside of the ~/.zshenv file and everything is working now.
I am using pycharm professional 2021.3.1 and ubuntu 18.04
I can attach to any process running directly on the host
However if the process is running inside a container (no matter what host privileges' I gave it)
I cannot attach. I get the following error
"Connection to python debugger failed Accept timeout'
I Tried on another computer and got the same results
Is this a known issue? Are there any work arounds? Except for using remote debugger (which requires adding extra code to the production code)
I found a way, it is not documented (as far as I can tell) but since it is for debugging only I will continue with it
Pycharm Professional set the IDE like you would for remote debug server
https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html#remote-debug-config
In the docker file of the containers that you wish to debug always install:
gdb
pydevd-pycharm
After the container and the process is up go into the container and run
"python3 /usr/local/pydevd_attach_to_process/attach_pydevd.py --port port_set_in_pycharm --pid pid_of_process_to_debug_in_container_id --host ip_of_the_host_running_the_pycharm"
the following is the same command pycharm uses when you do attach to process
now you can put breakpoints and debug normally
Advantage of this solution in contrast to remote debug defined in the pycharm documentation is that we do not have to add code to the production code
I have learned to use docker as development server (LAMP and MEAN) and now I feel I should take next step, By removing PHP and node binaries from system and use binaries from containers. So on a fresh Solus install, I setup containers for PHP, node, Ruby etc. Solus already recommends using containers for such tasks. But I got stuck on first day.
I installed vs code (Code-oss) on installed extensions (prettier, PHPCS etc) on it, and they need path of installed binaries (path/to/phpcs, path/to/node etc).
I initially set up configuration path as
docker run -it --rm herloct/phpcs phpcs
based on https://gist.github.com/barraq/e7f85262bc7a0af2d8d8884d27b62d2c but using more updated container. It didn't work, So I set it up as alias thinking it would fool VSCode into thinking it is native command, but it didn't work either. I have confirmed that using those command directly from terminal does work, But VSCode PHPIntellisense extension does not want to work.
Any suggestion?
P.S. Any tip to keep container running in background as to avoid container bootup delay everytime I use PHPCS or javac from container? I can keep LAMP server running but everytime I enter terminal tools, it loads up new container to execute command, and then kill container causing delay for bootup and closing.
In case it is still relevant to someone: You might want to create a VS Code development container to use dockerized binaries.
For this to work, a .devcontainer.json is required which could be as simple as:
{
"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12"
}
I'm trying to streamline my iOS development builds and read about Docker.
If I understood it right, I could create an image that would include all the dependencies and my fellow devs could just pull it and build inside it.
Point is now, does this also work with Fastlane (which uses the Xcode cli tools I think) and "Docker for Mac"?
Also, I'm using React-Native, which seems to start a second process for bundling the JavaScript that will be included in the native build later and I read Docker only allows one process, is this a problem?
The problem with using Docker is that even if you use Docker for mac, you won't have access to macOS-based images. Docker runs in a lightweight virtual machine called xhyve - at least if you install docker via the Docker for Mac package - that runs Linux on your mac.
Essentially what this means is that your docker container is going to be limited to non-Xcode functionality. Here's what you definitely won't be able to do, at least not without a non-trivial amount of work:
Compile your app's native code
Take screenshots of your app or run your app in the Simulator
Signing the finished app with Apple's codesign
Here's things that you could potentially use your docker container for:
Building the JS code (I assume, since RN should work on Linux)
Uploading your app with iTMSTransporter (i.e. using fastlane's deliver)
Downloading/Creating certificates, provisioning profiles and push certificates (i.e. fastlane's match, cert, pem and sigh)
Working with git
All in all you're probably going to be very limited. Instead, it would be advisable to use things like Gemfile and Brewfile to list all your dependencies, and have a small setup.sh script that runs brew bundle and bundle install to install them on your colleague's machines. You can also set it up to run those during building (with Xcode's script build phases), so that no one can accidentally forget to install something that is needed for the build.
That being said, there is a fastlane docker image that is being worked on here that is also available on the Docker Hub. Note that it has only ever been tested to run the fastlane tests (that don't depend on macOS-only software), so it doesn't actually claim to run fastlane reliably.
I read Docker only allows one process
Docker allows multiple processes, it just doesn't allow more than one main process. If your main process stops everything else and the container stops with it. If you just want to use it to install dependencies so that you can run one-off commands that use them, instead of hosting a long-running service, you can always do that by using docker run:
docker run <repo/image:tag> <your_command>
Or launch an interactive shell into the container:
docker run -it <repo/image:tag> /bin/bash
I've just installed redis on windows with MSOpenTech port. Everything is fine but the windows service. In order to run cmd, I need to create Redis command line arguments which I don't know how to achieve.
How can I solve this problem?
This is the instruction:
Running Redis as a Service
In order to better integrate with the Windows Services model, new
command line arguments have been introduced to Redis. These service
arguments require an elevated user context in order to connect to the
service control manager. If these commands are invoked from a
non-elevated context, Redis will attempt to create an elevated context
in which to execute these commands. This will cause a User Account
Control dialog to be displayed by Windows and may require
Administrative user credentials in order to proceed.
Installing the Service
--service-install
This must be the first argument on the redis-server command line.
Arguments after this are passed in the order they occur to Redis when
the service is launched. The service will be configured as Autostart
and will be launched as "NT AUTHORITY\NetworkService". Upon successful
installation a success message will be displayed and Redis will exit.
This command does not start the service.
For instance:
redis-server --service-install redis.windows.conf --loglevel verbose
Uninstalling the Service
--service-uninstall
In dir where you installed redis instead of
redis-server --service-install redis.windows.conf--loglevel verbose
do
redis-server --service-install redis.windows.conf --loglevel verbose
(i.e. Add a space before "--loglevel")
Similar to starting redis from command line, before installing the service you will need to specify the maxheap parameter. Open the redis.windows.conf file and find the line which comments out maxheap; specify a suitable size in bytes.
Then run
redis-server --service-install redis.windows.conf --loglevel verbose
You will need to manually start the service after you install it or just restart windows.
The simplest way is,
run command prompt as an administrator and than open redis directory and write
redis-server --service-install redis.windows.conf --loglevel verbose
the service will successfully installed.
For me as mentioned here, Redis doesn't start as windows service on Windows7
by installing the service with --service-name parameter runs the service magically without any issue.
The Microsoft Redis Open Tech project has been abandoned and no longer supported.
Memurai is a Windows port of Redis that derives from that Open Tech project (see here). It is actively maintained and supported.
Take a look.