6

I have install Jenkins on Ubuntu VPS and I am doing a nodejs build, which, at some point triggers a 502 bad gateway in nginx and the Jenkis service stops.

The build seems to stop at random times, sometimes when installing the npm models, other times when using gulp and so on.

I have to restart it manually (sudo service jenkins restart).

Here is the console output from a build:

+ jspm -v
0.16.15
Running against local jspm install.
[workspace] $ /bin/sh -xe /tmp/hudson1116016846111302145.sh
+ jspm install
     Looking up npm:babel-core
     Looking up npm:babel-runtime
     Looking up npm:core-js
     Updating registry cache...
ok   Up to date - babel as npm:babel-core@^5.8.24 (5.8.34)
     Looking up github:jspm/nodelibs-fs
     Looking up github:jspm/nodelibs-path
     Looking up github:jspm/nodelibs-process
     Looking up github:systemjs/plugin-json
     Looking up npm:process
     Looking up npm:path-browserify
     Looking up github:jspm/nodelibs-assert
     Looking up npm:assert
     Looking up npm:util
     Looking up npm:inherits
     Looking up github:jspm/nodelibs-util
ok   Up to date - core-js as npm:core-js@^1.1.4 (1.2.6)
ok   Up to date - babel-runtime as npm:babel-runtime@^5.8.24 (5.8.34)
ok   Install tree has no forks.

ok   Install complete.
[workspace] $ /bin/sh -xe /tmp/hudson4025483240884121474.sh
+ npm run build
> dxx-app@1.0.0 build /var/lib/jenkins/jobs/dxx-app/workspace
> gulp build

[15:31:11] Using gulpfile ~/jobs/dxx-app/workspace/gulpfile.js
[15:31:11] Starting 'build'...
[15:31:11] Starting 'clean'...
[15:31:11] Finished 'clean' after 19 ms
[15:31:11] Starting 'jspm-build'...
[15:31:11] Starting 'copy-assets'...
[15:31:11] Starting 'copy-fonts'...
[15:31:11] Starting 'less'...
[15:31:11] Finished 'copy-assets' after 226 ms
[15:31:12] Finished 'less' after 191 ms
[15:31:12] Finished 'copy-fonts' after 213 ms

502 Bad Gateway

nginx/1.4.6 (Ubuntu)

The proble is, when Jenkis fails, it does not record anything in my build logs, so I do not know what is happening.

I have seen online you should increase the timeout from the nginx.conf, so I have added the following to the config file:

http {

        ##
        # Increased timeout to fix 502 bad gateway error
        ##
        fastcgi_buffers 800 10006k;
        fastcgi_buffer_size 1000k;
        fastcgi_connect_timeout 999999;
        fastcgi_send_timeout 999999;
        fastcgi_read_timeout 999999;


Also, in nginx, sites-available, I have the following configuration:




server {
        listen 80;
        server_name jenkins.domain.com;

        ignore_invalid_headers off;

        location / {
                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header        X-Forwarded-Proto $scheme;
                proxy_pass              http://127.0.0.1:8080;
                proxy_connect_timeout   999999999999;
                proxy_send_timeout      999999999999;
                proxy_read_timeout      999999999999;
        }
}

Do you have any ideas?

Dany D
  • 1,189
  • 2
  • 18
  • 44
  • Could you fix your problem? – plainerman Sep 14 '17 at 14:48
  • 1
    I got the same issue. Could be that your server kills the process because it is using too much RAM? – flaudre Sep 17 '17 at 08:09
  • Someone with some update about this one? Right now I'm experiencing same issue with a react project. When Jenkins starts with the 'npm build' step, it get stuck there and when I try to refresh or click in other links in Jenkins page, it shows me the 502 Bad Gateway error from nginx. I've tried from other sources many things included with the timeout, and increasing memory.. – Joe Lewis Oct 10 '19 at 12:34
  • @JoeLewis - did you have any luck with this? I also have a react project and getting the same thing on the 'npm build' step... any advice/input would be greatly appreciated :) – Aaron Apr 17 '20 at 08:59

3 Answers3

0

As explained in this thread you can increase the memory in the /etc/default/jenkins where you can adjust the following flag

JAVA_ARGS="-Xmx256m" # Choose your desired memory instead of 256
flaudre
  • 2,358
  • 1
  • 27
  • 45
0

I had the same issue in Ubuntu server. I updated the JAVA_ARGS nano /etc/default/jenkins JAVA_ARGS="-Xmx256m" it worked for me.

0

I experienced the same issue on Ubuntu server. I had to change JAVA_ARGS value in

/etc/default/jenkins

to:

JAVA_ARGS="-Xmx128m"

before the react build process stopped throwing 502 gateway error message. This is on Jenkins 2.263.4