Starting nodejs asynchronous from Jenkins - node.js

I am currently implementing some mock http host using a node.js server. This server should be started by a jenkins CI job. After its started integration tests from JMeter should be performed and afterwards the node.js server should be shut down.
Right now i am having the problem that i can without problem start the node.js server as well as the jmeter test file alone. The problem is, that the node.js execution blocks the Jenkins Job and therefore the JMeter tests which are launched after Node are never actually started. Therefore i was wondering if there is a way to start a node.js server in the background, let it listen until the JMeter tests are over then shut it down again.
I guess the shutdown can be achieved using some special request to the nodejs server, but the main problem is that starting the nodejs http server blocks the entire jenkins process and thus the JMeter tests never start.
Is there a way to tell Jenkins that it should start the nodejs server but should not wait for it to end? Thanks in advance, Cromon

Related

stop and restart node.js server from another server

I have two server running in node.js. A main server and a maintenance server. Is there a possibility to stop/start the main server out of the maintenance server? Both running on the same system. At the moment, I start both manually via the package.json.
Happy for some help!

How to auto-restart rabbitmq after crashing

I experienced some crash for rabbitmq on my Linux server. To restart it, I execute the following command:
systemctl restart rabbitmq-server.service
The server restarts correctly.
Another problem is that I have to restart all the Node applications that were connected to rabbitmq before crashing.
Here are my questions:
Is there a way to automatically restart rabbitmq when crashing?
How to make my Node applications automatically reconnect to rabbitmq?
Thanks very much for your help!
Thierry
So to answer your first question , the best way to handle it is run the RabbitMQ cluster on docker and have the container restart mode set to always so in case if a node goes down for some reason the container will stop and the docker deamon will spawn a new container for it , if you can use K8s then it is even better.
For our second question the general pattern that we follow in Client applications is to have a reconnect logic which is triggered whenever there is an IO Exception and the reconnect attempt is continued for configured number of times with some wait added in between each attempt. There is no automatic way to do this and has to be handled as part of my client app.

nodejs for background process, not a http server

Im new to nodejs, i am looking for a way to create a nodejs process that can run in the background. All the example I can find is to create a node http server. I don't need to listen for any web request i just need to startup a process and have it listen to a message queue.
NodeJS has enough API to be used for versatile tasks, not just HTTP Servers. You have two problems to solve:
Run Node process continuously. So, you'd need some equivalent of http.listen() so the process just don't exit. Whatever you intent to do, you'd probably need Node waiting for some external events.
Run node as a daemon or service. There are plenty of modules to help, foreman, pm2. You can make this process auto-start by using upstart on linux machines and node-window for windows.

Run at startup and monitor redis and node.js processes

I want to deploy node.js app which depends on redis. Both processes will run on the same VPS. There are plenty of examples on how to daemonize and monitor node and I've also found some uncommented configuration for redis. How do I put it together? Can I just combine these two snippets in one monitrc file?
You could use Supervisord to orchestrate the launch of Redis and your NodeJS apps (use the priority parameter to start Redis before your apps). Supervisord will automatically restart your NodeJS app if they crash.
You can then setup monit over it to be alerted when something wrong happens and to restart your NodeJS processes if they use too much memory/cpu or if they are not accessible anymore from a specific port.

node.js app running using forever inaccessible after a while

I have a node.js server and a java client communicating using socket.io. I use this api https://github.com/Gottox/socket.io-java-client for the java client. I am using forever module
to run my server.
Everything works well but after some time , my server becomes inaccessible and I need to restart it, Also, most of the times i need to update/edit my node.js server file in order to make my server work again (restarted). Its been two weeks already and im still keep restarting my server :(.
Has anyone run into the same problem ? and solution or advice please.
Thanks

Resources