Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I change the jenkins listening port? #659

Open
arjunprabhulal opened this issue Oct 23, 2016 · 4 comments
Open

How do I change the jenkins listening port? #659

arjunprabhulal opened this issue Oct 23, 2016 · 4 comments
Labels

Comments

@arjunprabhulal
Copy link

I installed apache tomcat from puppetforge labs which was running at port 8080.

I did some testing and installed jenkins from puppetforge which puppet agent shows as running and doesnt throw any error in catalog as port 8080 is used by Java/tomcat

Puppet agent logs

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for arjunp5.mylabserver.com
Info: Applying configuration version '1477200872'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/Archive[credentials.hpi]/ensure: replace archive: /var/lib/jenkins/plugins/credentials.hpi from (sha1)e099761bcc712d4f750444913e4fa3d07dbc66e2 to (sha1)
Info: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/Archive[credentials.hpi]: Scheduling refresh of Service[jenkins]
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/owner: owner changed 'root' to 'jenkins'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/group: group changed 'root' to 'jenkins'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/seluser: seluser changed 'unconfined_u' to 'system_u'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/seltype: seltype changed 'user_tmp_t' to 'var_lib_t'
Notice: /Stage[main]/Jenkins::Service/Service[jenkins]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Jenkins::Service/Service[jenkins]: Unscheduling refresh on Service[jenkins]

When I checked the status also , its showing running

[root@arjunp5 opt]# /etc/rc.d/init.d/jenkins restart
Restarting jenkins (via systemctl): [ OK ]
[root@arjunp5 opt]# /etc/rc.d/init.d/jenkins status
● jenkins.service - LSB: Jenkins Continuous Integration Server
Loaded: loaded (/etc/rc.d/init.d/jenkins)
Active: active (exited) since Sun 2016-10-23 05:24:13 UTC; 6s ago
Docs: man:systemd-sysv-generator(8)
Process: 5123 ExecStop=/etc/rc.d/init.d/jenkins stop (code=exited, status=0/SUCCESS)
Process: 5129 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)

Oct 23 05:24:12 arjunp5.mylabserver.com systemd[1]: Starting LSB: Jenkins Continuous Integration Server...
Oct 23 05:24:12 arjunp5.mylabserver.com runuser[5131]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Oct 23 05:24:13 arjunp5.mylabserver.com jenkins[5129]: Starting Jenkins [ OK ]
Oct 23 05:24:13 arjunp5.mylabserver.com systemd[1]: Started LSB: Jenkins Continuous Integration Server.

When I start manually from jenkins , it shows below error

[root@arjunp5 opt]# java -jar /usr/lib/jenkins/jenkins.war
Running from: /usr/lib/jenkins/jenkins.war
webroot: $user.home/.jenkins
Oct 23, 2016 5:28:13 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Logging initialized @646ms
Oct 23, 2016 5:28:13 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
Oct 23, 2016 5:28:15 AM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: Empty contextPath
Oct 23, 2016 5:28:15 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: jetty-9.2.z-SNAPSHOT
Oct 23, 2016 5:28:16 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
Jenkins home directory: /root/.jenkins found at: $user.home/.jenkins
Oct 23, 2016 5:28:17 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started w.@652a7737{/,file:/root/.jenkins/war/,AVAILABLE}{/root/.jenkins/war}
Oct 23, 2016 5:28:17 AM org.eclipse.jetty.util.log.JavaUtilLog warn
WARNING: FAILED ServerConnector@50fe837a{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Address already in use
java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)

Actually my 8080 port is already in use ,which is not captured during jenkins status / not in puppet catalog , when i killed my tomcat Java process , tried puppet agent -t , it showed same puppet log , but now jenkins was actually running

[root@arjunp5 opt]# netstat -tulpn | grep :8080
tcp6 0 0 :::8080 :::* LISTEN 2127/java
[root@arjunp5 opt]# netstat -plten |grep java
tcp6 0 0 :::8009 :::* LISTEN 1002 52705 2127/java
tcp6 0 0 :::8080 :::* LISTEN 1002 52701 2127/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 1002 52719 2127/java
[root@arjunp5 opt]# kill -9 2127
[root@arjunp5 opt]# netstat -plten |grep java

[root@arjunp5 opt]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for arjunp5.mylabserver.com
Info: Applying configuration version '1477200872'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/Archive[credentials.hpi]/ensure: replace archive: /var/lib/jenkins/plugins/credentials.hpi from (sha1)e099761bcc712d4f750444913e4fa3d07dbc66e2 to (sha1)
Info: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/Archive[credentials.hpi]: Scheduling refresh of Service[jenkins]
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/owner: owner changed 'root' to 'jenkins'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/group: group changed 'root' to 'jenkins'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/seluser: seluser changed 'unconfined_u' to 'system_u'
Notice: /Stage[main]/Jenkins::Config/Jenkins::Plugin[credentials]/File[/var/lib/jenkins/plugins/credentials.hpi]/seltype: seltype changed 'user_tmp_t' to 'var_lib_t'
Notice: /Stage[main]/Jenkins::Service/Service[jenkins]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Jenkins::Service/Service[jenkins]: Unscheduling refresh on Service[jenkins]
Notice: Applied catalog in 2.34 seconds

So , Puppet module " Jenkins " doesnt check if the Port 8080 is already in use or not ?

@nikkonix
Copy link

Hello,
I am facing the same issue. My 8080 is occupied by another app.
To avoid the issue, I am specifying in my manifest HTTP_PORT 9090 for Jenkins and still happening. Init.d script is checking 8080, module does not changed it as it should.

class{ 'jenkins':
config_hash => {
'HTTP_PORT' => { 'value' => '9090'},
}
}

  • Starting Jenkins Continuous Integration Server jenkins
    The selected http port (8080) on address 0.0.0.0 seems to be in use by another program

Please advice, if you are going to fix this soon.
Thank you in advance

@jhoblitt
Copy link
Member

Unfortunately, the upstream debian and redhat packaging use different sysconf values.

HTTP_PORT is used by debian
https://github.com/jenkinsci/packaging/blob/master/deb/build/debian/jenkins.default#L57

JENKINS_PORT is used by redhat
https://github.com/jenkinsci/packaging/blob/master/rpm/build/SOURCES/jenkins.sysconfig.in#L56

There's not much we can do until the upstream packaging is fixed. I would be happy to accept a doc PR.

@jhoblitt jhoblitt changed the title Puppet agent shows Jenkins running but port 8080 is used by Tomcat How do I change the jenkins listening port? Dec 30, 2016
@englianhu
Copy link

englianhu commented Oct 31, 2021

Unfortunately, the upstream debian and redhat packaging use different sysconf values.

HTTP_PORT is used by debian https://github.com/jenkinsci/packaging/blob/master/deb/build/debian/jenkins.default#L57

JENKINS_PORT is used by redhat https://github.com/jenkinsci/packaging/blob/master/rpm/build/SOURCES/jenkins.sysconfig.in#L56

There's not much we can do until the upstream packaging is fixed. I would be happy to accept a doc PR.

d7h2p4b5ev

🐧 Linux
🍥 Debian
👒 Redhat
🟠 Ubuntu
🏔 ArchLinux
🐉 KaliLinux

Using 🟠Ubuntu 20.04LTS, tried to modify the port number from 8080 to 8082, updated and restarted but doesn't work.

+:~$ systemctl start jenkins.service
Job for jenkins.service failed because the control process exited with error code.
See "systemctl status jenkins.service" and "journalctl -xe" for details.
+:~$ systemctl status jenkins.service
● jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: failed (Result: exit-code) since Sun 2021-10-31 16:19:42 JST; 10s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 154642 ExecStart=/etc/init.d/jenkins start (code=exited, status=7)

!Warning: The unit file, source configuration file or drop-ins of jenkins.service changed on di>
● jenkins.service - LSB: Start Jenkins at boot time
     Loaded: loaded (/etc/init.d/jenkins; generated)
     Active: failed (Result: exit-code) since Sun 2021-10-31 16:19:42 JST; 3min 1s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 154642 ExecStart=/etc/init.d/jenkins start (code=exited, status=7)

Oct 31 16:19:41 Scibrokes-Trading systemd[1]: Starting LSB: Start Jenkins at boot time...
Oct 31 16:19:41 Scibrokes-Trading jenkins[154642]: Correct java version found
Oct 31 16:19:41 Scibrokes-Trading jenkins[154642]:  * Starting Jenkins Automation Server jenki>
Oct 31 16:19:41 Scibrokes-Trading jenkins[154642]: The selected http port (8080) on address 0.>
Oct 31 16:19:41 Scibrokes-Trading jenkins[154642]: Please select another address/port combinat>
-Oct 31 16:19:42 Scibrokes-Trading jenkins[154642]:    ...fail!
Oct 31 16:19:42 Scibrokes-Trading systemd[1]: jenkins.service: Control process exited, code=ex>
-Oct 31 16:19:42 Scibrokes-Trading systemd[1]: jenkins.service: Failed with result 'exit-code'.
-Oct 31 16:19:42 Scibrokes-Trading systemd[1]: Failed to start LSB: Start Jenkins at boot time.
+:~$ systemctl daemon-reload
+:~$sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
time
ated)
un 2021-10-31 16:24:13 JST; 45s ago


tarting LSB: Start Jenkins at boot time...
7]: Correct java version found
7]:  * Starting Jenkins Automation Server jenkins
-7]: The selected http port (8080) on address 0.0.0.0 seems to be in use by another program
-7]: Please select another address/port combination to use for jenkins
-7]:    ...fail!
jenkins.service: Control process exited, code=exited, status=7/NOTRUNNING
jenkins.service: Failed with result 'exit-code'.
-failed to start LSB: Start Jenkins at boot time.

Reference:

@englianhu
Copy link

englianhu commented Nov 1, 2021

May try to set +e as refer from:

The error still there and then changed port number as below and works.

:~$ sudo micro /etc/default/jenkins

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8082

:~$ sudo service jenkins restart
:~$ sudo systemctl status jenkins
:~$ #and then update the system
:~$ sudo apt update
:~$ apt list --upgradable
:~$ sudo apt upgrade

jenkins started by refer to source : https://stackoverflow.com/a/28341352/3806250

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants