-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Install as a systemd Service
John Pearcey edited this page Aug 15, 2024
·
2 revisions
Unpack the GitBucket Zip distribution to /opt
.
Followings will be assumed:
- Java 8 is running correctly with
/usr/bin/java
- Install directory is
/opt/gitbucket
- The GitBucket (java) process will run as user
gitbucket
and groupgitbucket
, with UID and GID 555 - A non-root user account that can use
sudo
to execute commands asroot
will be the example
- Add the user and the group:
sudo groupadd -g 555 gitbucket
sudo useradd \
-g gitbucket --no-user-group \
--home-dir /opt/gitbucket --no-create-home \
--shell /usr/sbin/nologin \
--system --uid 555 gitbucket
- Make the owner of the GitBucket to be the
gitbucket:gitbucket
user:
sudo chown -R gitbucket:gitbucket /opt/gitbucket
- Change
gitbucket.service
to suit your needs. A basic file to get you going will be something like this:
Description=Git hosting service
[Service]
User=gitbucket
ExecStart=/usr/bin/java -jar /opt/gitbucket/gitbucket.war --host=0.0.0.0 --port=8080 --gitbucket.home=/opt/gitbucket/<data-dir>
[Install]
WantedBy=multi-user.target
- Install the
systemd
service unit configuration file, reload thesystemd
daemon, and start GitBucket:
sudo cp gitbucket.service /etc/systemd/system/
sudo chown root:root /etc/systemd/system/gitbucket.service
sudo chmod 644 /etc/systemd/system/gitbucket.service
sudo systemctl daemon-reload
sudo systemctl start gitbucket.service
- Start GitBucket automatically when booting:
sudo systemctl enable gitbucket.service
- If GitBucket is not starting properly, view the logs:
journalctl --boot -u gitbucket.service
or just follow the logs with:
journalctl -f -u gitbucket.service