Run gitblit as a service at ubuntu

1,720 views
Skip to first unread message

Sandra Warmbrunn

unread,
Jul 30, 2013, 5:04:49 AM7/30/13
to git...@googlegroups.com
Hello,

I'm a linux newbie. I installed gitblit on my ubuntu server and I installed and configured an Apache and it works fine when I run gitblit.sh.
I run install-service-ubuntu.sh and it copies all scripts, but when I run service-ubuntu.sh I get the following error message:

start-stop-daemon: user 'gitblit' not found

I have read that I need a gitblit user, but with which permissions and in which group? Can anybody help me?

best regards 
Sandra 

Tamas Papp

unread,
Jul 30, 2013, 5:26:49 AM7/30/13
to git...@googlegroups.com
hi,

Just create a user, that is able to run the service and has write permission to the base folder.
Eg.:

groupadd -g 2000 gitblit
useradd -u 2000 -g 2000 -s /bin/bash -d /data/gitblit/base/folder gitblit


Where the home directory is the $GITBLIT_BASE_FOLDER from the init script.


Cheers,
tamas

Sandra Warmbrunn

unread,
Jul 30, 2013, 6:12:23 AM7/30/13
to git...@googlegroups.com
Hello tamas,

thank you. But I get the following error message:

start-stop-daemon: unable to open pidfile '/var/run/gitblit.pid' for writing (Permission denied)
 :)

best regards 

Sandra Warmbrunn

unread,
Jul 30, 2013, 6:47:30 AM7/30/13
to git...@googlegroups.com
I installed acl and add gitblit group to /var/run/ and set permissions. When I start the service I have no error message, but the service is not startet. with ps -ax I don't see it and 
I have no result at localhost:8084 (I have change the http Port), when I start gitblit I have a result at localhost:8084 

Tamas Papp

unread,
Jul 30, 2013, 6:49:15 AM7/30/13
to git...@googlegroups.com
/var/run should be  17777.
Or you run gitblit as root previously and a pid file left there.

tamas

Tamas Papp

unread,
Jul 30, 2013, 7:01:42 AM7/30/13
to git...@googlegroups.com
On 07/30/2013 12:47 PM, Sandra Warmbrunn wrote:
>
> I installed acl and add gitblit group to /var/run/ and set permissions.

You really should use sticky bit.

> When I start the service I have no error message, but the service is not startet. with ps -ax I
> don't see it and
> I have no result at localhost:8084 (I have change the http Port), when I start gitblit I have a
> result at localhost:8084

Check the logs.

My service is running with this option:

-Dlog4j.configuration=file://${GITBLIT_BASE_FOLDER}/log4j.properties

My log4j.properties file:

#------------------------------------------------------------------------------
#
# The following properties set the logging levels and log appender. The
# log4j.rootCategory variable defines the default log level and one or more
# appenders. For the console, use 'S'. For the daily rolling file, use 'R'.
# For an HTML formatted log, use 'H'.
#
# To override the default (rootCategory) log level, define a property of the
# form (see below for available values):
#
# log4j.logger. =
#
# Available logger names:
# TODO
#
# Possible Log Levels:
# FATAL, ERROR, WARN, INFO, DEBUG

#------------------------------------------------------------------------------
log4j.rootCategory=INFO, S, R

#log4j.rootLogger=INFO
#log4j.logger.org=INFO
#log4j.logger.com=INFO
#log4j.logger.net=INFO

#log4j.logger.com.gitblit=INFO

log4j.logger.org.apache.wicket=INFO
log4j.logger.org.apache.wicket.RequestListenerInterface=INFO
log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO

#------------------------------------------------------------------------------
#
# The following properties configure the console (stdout) appender.
# See http://logging.apache.org/log4j/docs/api/index.html for details.
#
#------------------------------------------------------------------------------
log4j.appender.S = org.apache.log4j.ConsoleAppender
log4j.appender.S.layout = org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern = %-5p %m%n

#------------------------------------------------------------------------------
#
# The following properties configure the Daily Rolling File appender.
# See http://logging.apache.org/log4j/docs/api/index.html for details.
#
#------------------------------------------------------------------------------
log4j.appender.R = org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File = /var/log/gitblit/gitblit.log
log4j.appender.R.Append = true
log4j.appender.R.DatePattern = '.'yyy-MM-dd
log4j.appender.R.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n

#------------------------------------------------------------------------------
#
# The following properties configure the Rolling File appender in HTML.
# See http://logging.apache.org/log4j/docs/api/index.html for details.
#
#------------------------------------------------------------------------------
log4j.appender.H = org.apache.log4j.RollingFileAppender
log4j.appender.H.File = /var/log/gitblit/gitblit.html
log4j.appender.H.MaxFileSize = 100KB
log4j.appender.H.Append = false
log4j.appender.H.layout = org.apache.log4j.HTMLLayout



Unfortunately this file is not shipped by default with release (James, why not?).
You can find it in the source folder:

./src/main/java/log4j.properties


tamas

James Moger

unread,
Jul 30, 2013, 7:46:06 AM7/30/13
to git...@googlegroups.com

Unfortunately this file is not shipped by default with release (James, why not?).
You can find it in the source folder:

./src/main/java/log4j.properties


Actually, it is shipped and used.  It's built-in to the jar.

I'll give it some thought to package it as you suggest with the GO build.

-J

Sandra Warmbrunn

unread,
Jul 30, 2013, 11:28:03 AM7/30/13
to git...@googlegroups.com
sorry, but no result, no log files, no running service, no running jetty. :(
I see this on the console:
Starting gitblit server
but when I look at ps -ax I see no jetty, no java process and no gitblit webside. :(
I'm despaired and angry. I'm an angry nerd!!!!! :(

Sandra Warmbrunn

unread,
Jul 30, 2013, 12:15:35 PM7/30/13
to git...@googlegroups.com
I only can start the service as root. I think I have not the permissions to start the service with the gitblit user.
What I must do to start it with the gitblit user? 

Tamas Papp

unread,
Jul 30, 2013, 12:19:17 PM7/30/13
to git...@googlegroups.com
On 07/30/2013 05:28 PM, Sandra Warmbrunn wrote:
> sorry, but no result, no log files, no running service, no running jetty. :(
> I see this on the console:
> Starting gitblit server
> but when I look at ps -ax I see no jetty, no java process and no gitblit webside. :(
> I'm despaired and angry. I'm an angry nerd!!!!! :(
>

Run init script with sh -x then run the start command from cli. Probably some switches has to be
left out.
Or even you can use strace to find out where it stuck.

tamas

Tamas Papp

unread,
Jul 30, 2013, 4:24:38 PM7/30/13
to git...@googlegroups.com
On 07/30/2013 01:46 PM, James Moger wrote:
>
> Actually, it is shipped and used. It's built-in to the jar.

Ough, I see.

> I'll give it some thought to package it as you suggest with the GO build.

I've attached my init script and corresponding defaults file (I sent it to the list earlier one time).

Feel free to use it or modify for your taste or whatever if it helps and good idea.
It works quite well for me.

Cheers,
tamas
gitblit-defaults
gitblit-ubuntu-init.sh

Sandra Warmbrunn

unread,
Jul 31, 2013, 5:19:57 AM7/31/13
to git...@googlegroups.com
Thank you so much for your help. I have a log :) yuchu  funny :)

But I have an Exception :)

AbstractLifeCycle [WARN] FAILED SslSelectChannelConnector@localhost:443: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:137)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:77)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
at org.eclipse.jetty.server.ssl.SslSelectChannelConnector.doStart(SslSelectChannelConnector.java:631)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.Server.doStart(Server.java:286)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.gitblit.GitBlitServer.start(GitBlitServer.java:396)
at com.gitblit.GitBlitServer.main(GitBlitServer.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.moxie.MxLauncher.main(MxLauncher.java:129)

Sandra Warmbrunn

unread,
Jul 31, 2013, 5:37:15 AM7/31/13
to git...@googlegroups.com
IT WORKS :) :) :) I'm so happy. Thank you.

In my gitblit.properties file I have found 443 as ssl Port and I have learned ports less then 1024 require root permissions. :) So I set the ssl Port be 8443. :)
For all directories and files used by gitblit, the gitblit user or gitblit group must have rwx permissions. 

For example:

chown -R root.gitblit /opt/gitblit

So it works, and now I must install oracle for jira and confluence. That will be a lot of fun, too.  yeah :( 

Tamas Papp

unread,
Jul 31, 2013, 5:37:54 AM7/31/13
to git...@googlegroups.com
On 07/31/2013 11:19 AM, Sandra Warmbrunn wrote:
Thank you so much for your help. I have a log :) yuchu  funny :)

But I have an Exception :)

AbstractLifeCycle [WARN] FAILED SslSelectChannelConnector@localhost:443: java.net.SocketException: Permission denied
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:137)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:77)
at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:187)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:265)
at org.eclipse.jetty.server.ssl.SslSelectChannelConnector.doStart(SslSelectChannelConnector.java:631)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.Server.doStart(Server.java:286)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.gitblit.GitBlitServer.start(GitBlitServer.java:396)
at com.gitblit.GitBlitServer.main(GitBlitServer.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.moxie.MxLauncher.main(MxLauncher.java:129)


You cannot bind services to low (< 1024) IP port as a normal user.

tamas
Reply all
Reply to author
Forward
0 new messages