HTTP API Call to create consul watch & consul exec - consul

Currently I am using consul watch & consul exec commands to create watches as well as to run some bash commands. I would like to use http api calls instead of commands to automate my system.
Is there http equivalents to do this work ?
Any help would be appreciated. Thanks

Under "Consul SDK":
https://www.consul.io/downloads_tools.html
there are bunches of libraries in various languages to talk to Consul. I personally like Consulate, a Python API. you would be interested in the event call: http://consulate.readthedocs.io/en/stable/events.html The consul exec and watches commands both use the event system. I don't know the exact event(s) you would need to send to simulate an exec call, but I'm sure you can break out a watch, run an exec and see what it does. Worse case you would have to look into the Consul source(written in go).

Related

How to debug grpc calls between pods_

I have two pods interact with each other using grpc, how to debug grpc calls between those two pods?
I already try to set:
export GRPC_TRACE=all
export GRPC_VERBOSITY=DEBUG
then using kubectl logs <pod> -n namespces does not show up any grpc logs, how to debug grpc between pods?
It depends on what you want to debug: If you just want to know if there are communications on the Network, then you will have to add something outside of your 2 programs.
If you are the developer of these programs, you can add middlewares to the gRPC clients/servers to add trace (e.g, using OpenTelemetry tracing and Jaeger) to get cross-services traces (you can propagate traces IDs on the network).
Otherwise, without knowing what your programs are we can't help you only with environment variables.

Spring Boot: Starting multiple services using shell script (.sh)

I like to write a shell script for a backend server using Spring Boot (v2.1.1) to start multiple microservices in a certain order - some services depend on other to be running.
What is the 'best practice'?
Of course i could run the .jars like this (original post):
#!/bin/bash
java -jar myjar1.jar &
java -jar myjar2.jar &
java -jar myjar3.jar &
But this would start the .jars simultaneously, afaik.
How can i ensure, that a certain service myjar1.jar started properly and after that, another service myjar2.jar is started. Because every service is a SpringBootApplication i assume that there are certain possibilities to do so?!
I read this SO solution but I don't want to create any symlinks, because i just need that for development purposes.
Well it is very specific to your service as to when it gets started.
At process level, as soon as you execute the command service is running, so you will need your service to share the state when its up.
One way i can think of is in your script start the service, expose health api and check if its up. if it is move to next one. You need to make use of curl and sleep command in your scripts.
But I would like to know why you want to do that. Specially for your microservices, your services should not depend on each other. They may need some data, but they should be resilient to the fact that services may come and go. You should have a very strong reason to do as you are doing, cause in real world env, it is very difficult to ensure order is maintained.

runit call script with start/stop

I've some SysVinit scripts with start/stop, they are used for remote server deployment, as now i am using runit in other deployment purpose, and don't want to duplicate the scripts (maintenance reason). Is it possible that runit invokes these scripts? or other approach? Thank you in advance.
It is unlikely that you can use these scripts unmodified with runit. Runit expects the service started with run to remain in the foreground and not exit.
A SysVInit script expects the opposite behavior. Because it does not perform any process monitoring (and the lack of process monitoring is presumably why you are switching to runit), SysVInit scripts expect services to run in the background, and will exit after starting the service.
These are two fundamentally incompatible models.
You could consider using systemd instead of runit, which provides good process monitoring while also being able to follow processes that fork.

Use mocha with grunt-contrib-connect or through filesystem?

Is it better to use mocha with a local server through the grunt-contrib-connect task or just run it with grunt-mocha?
What are the differences/downsides of both?
They are two totally different things. You do not automatically run spec files with grunt-contrib-connect, it is meant to be used in conjunction with other tasks that hit the connect server. You can use it with grunt-mocha (see the urls option), but it's really only useful if you need to test with server logic. Otherwise, you can mock server responses and XHR requests in your tests using sinon.

What is the easiest way for Jenkins to perform an action on recieving an email?

I need a way to have Jenkins perform an action on receiving an email. I plan on sending an email with a Ruby script and net/smtp.
I'm also not aware of a plugin for Jenkins to start jobs via email. However, it is easy to use a service like CloudMailin (which converts the incoming email to an HTTP POST) and use a small script of your own to make this interact with the Jenkins API and schedule jobs.
I've done this personally and it works pretty well. I didn't make full use of the API and just used the following URL:
http://SERVER_URL/job/JOB_NAME/build?delay=60
You don't need the delay but I found it useful to ask multiple jobs to be set at the same time.
There is a plugin that lets you send commands to Jenkins via email. Haven't personally used it, but here it is:
https://wiki.jenkins-ci.org/display/JENKINS/Mail+Commander+Plugin

Resources