Hi,
I'm facing issue during Gerrit service start up.
The issue is related to systemd, and I do not sure this issue is common for other OS.
Could yoou please let me know if you faced similar issue or if you have more better workaround/solutions for this issue?
Environment
Gerrit: 3.4.8
OS: AmazonLinux 2023
Gerrit was installed on my server and then I run that by gerrit.service.
Gerrit process itself can be started and I can see WebUI for that but Gerrit sevice said Failed to start.
/etc/systemd/system/gerrit.service
---------------------------
# Systemd unit file for Gerrit
[Unit]
Description=Gerrit Code Review
After=syslog.target network.target remote-fs.target
[Service]
Type=forking
User=root
EnvironmentFile=/etc/default/gerritcodereview
ExecStart=<GERRIT-USER-HOME>/review_site/bin/gerrit.sh start
ExecStop=<GERRIT-USER-HOME>/review_site/bin/gerrit.sh stop
PIDFile=<GERRIT-USER-HOME>/review_site/logs/gerrit.pid
TimeoutStartSec = 3000
[Install]
WantedBy=multi-user.target
---------------------------
Error
There is no error mesage in error_logs(review_site/logs/error_log)
Found error during gerrit service start
# systemctl start gerrit
Job for gerrit.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status gerrit.service" and "journalctl -xeu gerrit.service" for details.
Check details for that like following.
# journalctl -xeu gerrit.service
----------------------------------------
(to gerrit) root on none
pam_unix(su-l:session): session opened for user gerrit(uid=xxxx) by (uid=0)
pam_unix(su-l:session): session closed for user gerrit
gerrit.sh[2289]: Starting Gerrit Code Review: OK
systemd[1]: gerrit.service: Refusing to accept PID outside of service control group, acquired through symlink chain: <GERRIT-USER-HOME>/review_site/logs/gerrit.pid
systemd[1]: gerrit.service: Refusing to accept PID outside of service control group, acquired through symlink chain: <GERRIT-USER-HOME>/review_site/logs/gerrit.pid
systemd[1]: gerrit.service: Failed with result 'protocol'.
----------------------------------------
That seems failed due to systemd, gerrit.pid was created once but removed by systemd.
I found 2 workaround for this issue
- run gerrit service by gerrit user
- modify gerrit.sh to run as root
both are worked but I do not sure which is better way.. which sould I take...
1. run gerrit service by gerrit user
Update gerrit.service to run gerrit by gerrit user.
like bellow.
------------------------------------------
change from
User=root
change to
User=gerrit
------------------------------------------
This worked with warning and it seems there is limitation regarding out of memory killer...
That said
------------------------------------------
gerrit.sh[2015]: <GERRIT-USER-HOME>/review_site/bin/gerrit.sh: line 347: ulimit: open files: cannot modify limit: Operation not permitted
gerrit.sh[2015]: Starting Gerrit Code Review: WARNING: Could not adjust Gerrit's process for the kernel's out-of-memory killer.
gerrit.sh[2015]: This may be caused by <GERRIT-USER-HOME>/review_site/bin/gerrit.sh not being run as root.
gerrit.sh[2015]: Consider changing the OOM score adjustment manually for Gerrit's PID=2062 with e.g.:
gerrit.sh[2015]: echo '-1000' | sudo tee /proc/2062/oom_score_adj
gerrit.sh[2015]: OK
systemd[1]: Started gerrit.service - Gerrit Code Review.
------------------------------------------
2.modify gerrit.sh to run as root
Update gerrit.service to change path of .pid file to the new location which is owned by root
Add several lines into "gerrit.sh" to change owner of .pid file to root
This worked fine without any error/warning.
But I need to take care this point if I upgrade Gerrit version in future...
I do not sure this issue is common for other OS.
Please let me know if you faced similar issue or if you have more better workaround/solutions for this.