Waiting on Nomad server - nomad

I am currently trying to build some integrations tests with Nomad.
For that I try:
nomad agent -dev -config=test.conf&
nomad run test.nomad
which of course fails, since it tries to submit the job before the server is running.
The bad option would be to insert a sleep.
My question is, whether there is a better way to wait until the server is up and accepts jobs.

So a only halfway hacky solution is:
wait_for_agent() {
while test -z $(curl -s http://127.0.0.1:4646/v1/agent/health)
do
sleep 1
done
}

Another hack :-)
nomad agent -dev -config=test.conf && nomad run test.nomad

Related

After jenkins job complete, the service also down

I have met a problem.
I used Jenkins to install haproxy and start the service, but after the job complete, the executor is free, and the haproxy daemon also disappear.
if I use sleep 30s after the service start, and the haproxy service will also alive at the 30s, after that, the haproxy daemon will down.
This behaviour is by design, as explained in ProcessTreeKiller. To avoid daemons spawned by the Jenkins build being terminated, add
export BUILD_ID=dontKillMe
to the beginning of your shell step.

Concourse CI - how to run functional tests?

we are in the middle of process migrating from Jenkins to Concourse CI and everything was pretty smooth so far. But now I have the issue, that I don't know how to solve. I would like to get any advices from the community.
What I am trying to do is a job that can run integrational or functional (web) tests using Selenium. There are few issues for us:
To run web tests I need to set up the database (and optionally, the searching engine, proxy and etc...) proxy to imitate the production environment as close at possible.
Ideally, it should be set up by docker-compose.
This database service should run in parallel of my tests
This database service should not return anything, neither error or success, because it only starts the database and nothing else
My web-tests should not be started until the database is ready
This database service should be stopped when all the web-tests were finished
As you can see, it's pretty non-trivial task. Of course, I can create an big uber-container that contains everything I need, but this is bad solution. Another option is to create a shell-script for that, but this is not flexible enough.
Is there any example how I could implement that or good practices for this issue?
Thanks!
Since version 1.3.0 it appears you can run Docker-compose in a task: https://github.com/concourse/concourse/issues/324
This appears to work:
jobs:
- name: docker-compose
public: true
serial: true
plan:
- do:
- task: docker-compose
timeout: 20m
privileged: true
config:
platform: linux
image_resource:
type: docker-image
source: {repository: "mumoshu/dcind", tag: "latest"}
run:
path: sh
args:
- -exc
- |
source /docker-lib.sh
start_docker
docker ps
docker-compose version
This is comment from author of Concourse:
There is no Docker binary or socket on the host - they're just running a Garden backend (probably Guardian). Concourse runs at an abstraction layer above Docker, so providing any sort of magic there doesn't really make sense.
The one thing missing post-1.3 is that Docker requires you to set up cgroups yourself. I forgot how annoying that is. I wish they did what Guardian does and auto-configure it, but what can ya do.
So, the full set of instructions is:
Use or a build an image with docker in it, e.g. docker:dind.
Run the following at the start of your task: https://github.com/concourse/docker-image-resource/blob/master/assets/common.sh#L1-L40
Spin up Docker with docker daemon &.
Then you can run docker-compose and friends as normal.
The downside of this is that you'll be fetching the images every time. #230 will address that.
In the long run, #324 (comment) is the direction I want to go.
See here https://github.com/concourse/concourse/issues/324
as in the accepted answer, the Slack archive data is deleted (due to Slack limit)
The docker image specialized for the usecase: https://github.com/meAmidos/dcind
It does not sound that complicated to me. I wrote a post on how to get something similar up and running here. I use some different containers for the stack and the test runner and fire up everything from an official docker:dind image with docker-compose installed on it...
Beyond the usual concourse CI stuff of fetching resources etc.
Performing a test-run would consist of :
Starting the web,rest, and other services with docker-compose up.
Starting the Testrunner service and fire the test-suites on the
web-page which communicates with the rest layer, which in turn is
dependent on the other services for responses.
Performing docker-compose down when the test-runner completes and
deciding the return-code of the task (0=fail, 1=success) based upon
the return code of the test-suite.
To cleanly setup and tear down the stack and test runner you could do something like the below, ( maybe you could use depends if your service is not started when the test begins, for me it works without)
# Setup the SUT stack:
docker-compose up -d
‌‌
# Run the test-runner container outside of the SUT to be able to teardown the SUT when testing is completed:
docker-compose run --rm test-runner --entrypoint '/entrypoint.sh /protractor/project/conf-dev.js --baseUrl=http://web:9000/dist/ --suite=my_suite'
‌‌
# Store the return-code from the tests and teardown:
rc=$?
docker-compose down
echo "exit code = $rc "
kill %1
exit $rc

Running a server with Ansible

I just started using Ansible and I am having trouble running a server.
I have a server which can be started using java -jar target/server-1.0-SNAPSHOT.jar. However, this will start the server and keep running forever displaying output, so Ansible never finishes.
This is what I tried that never finishes:
- name: Start server
command: chdir=~/server java -jar target/server-1.0-SNAPSHOT.jar
What is the proper way to do this?
Either create a service, as #udondan suggests, or use an asynchronous task to launch your server. http://docs.ansible.com/ansible/playbooks_async.html
As #Petro026 suggested, your choices are asynchronous task or creating a service.
I would strongly suggest against the asynchronous task approach. It's a very fragile solution:
What if the host is restarted?
What if you run your playbook twice?
What if your server app just dies?
Your best bet is to create a service for it, and probably the easiest approach for it would involve using a process control system like supervisord, which is supported by ansible.
From the supervisor docs:
Supervisor is a client/server system that allows its users to monitor
and control a number of processes on UNIX-like operating systems.
Put that in a PID and send the output to nohup.
Something like this:
nohup java -jar target/server-1.0-SNAPSHOT.jar &
In your playbook:
name: Start server
command: chdir=~/server nohup java -jar target/server-1.0-SNAPSHOT.jar &
If you want kill the process kill -9 #numerofpid.

Node Manager Stop - Hadoop 2.2.0

On invoking ./stop-yarn.sh, I get
"nodemanager did not stop gracefully after 5 seconds: killing with kill -9".
Is this something I should be concerned about? What should I do to avoid this error?
There is not way to do a graceful stop till yet. you can follow this link https://issues.apache.org/jira/browse/YARN-914 for tracking and feature changes.
The reason is because the Resource Manager (RM) is stopped before Node Manager (NM). The NM needs to unregister itself from the RM. So when NM tries to connect with RM (to unregister itself) it fails as RM is already stopped. And so a timeout occurs (after waiting 5 sec - mention in start-yarn.sh) causing NM to be killed and not allowing to stop gracefully.
You could use "hadoop job" to see if you have jobs still running and use the option "-kill " http://hadoop.apache.org/docs/r1.0.4/commands_manual.html#job

Apache 2 - reload config on Windows

I have a PHP script that modifies my httpd.conf file, so I need to automatically reload it in Apache.
On Linux, there is graceful restart, but on Windows (I use the restart command) it terminates all the current connections. Is there a command as graceful restart on Windows? Is there a workaround on this?
Yes, you should use the -k switch.
httpd.exe -k restart or apache.exe -k restart
More info here has well. http://www.zrinity.com/developers/apache/usage.cfm
Edit:
It shouldn't that is the point of Graceful. Notice I used the -k. That is not the same as a normal restart. It let's the current sessions complete their task while the config is being reread, so that it will start taking new requests immediately.
From the documentation:
The USR1 or graceful signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately.
http://httpd.apache.org/docs/2.2/stopping.html#graceful
It's doing what you are asking for.
Edit 2:
Adding this link and gave both possible versions because some people think you there is only one specific way to do something instead of search themselves.
http://httpd.apache.org/docs/2.4/platform/windows.html#wincons
I think I'm just going to delete this answer because either people can't read or if it doesn't work for someone it gets a DV. There are different windows versions made by different developers. If it doesn't work look for the answer from them. Even Linux has different commands depending on the distro. geez
In the newest Apache 2.4.20 VC10 the "httpd -k restart" command actually DOES do a graceful restart. It won't drop any connections, for example if somebody is downloading something from your server, it WILL NOT interrupt this process. One more proof is that "-k restart" will not reset your server statistics that mod_status provides, won't even alter the "Restart Time" value.
Although "httpd -k graceful" and "httpd -k graceful-stop" commands are available in Windows, but they will not work giving an error "couldn't make a socket".

Resources