1

I used the suggested answer from this post to make a custom service in my ubuntu 17.04 environment: Installing gitblit GO as service in Ubuntu Server 16.04

Unfortunately when I hit

sudo systemctl enable gitblit_server.service

I receive

Failed to enable unit: File gitblit_server.service: Invalid argument

as an error.

Any idea what I am doing wrong?


Update:

result for journalctl -xe

Sep 01 16:06:22 git-dmz01 sudo[7121]: msoadmin : TTY=pts/1 ; PWD=/etc/systemd/system ; USER=root ; COMMAND=/bin/systemctl enable gitblit_server.service
Sep 01 16:06:22 git-dmz01 sudo[7121]: pam_unix(sudo:session): session opened for user root by msoadmin(uid=0)
Sep 01 16:06:22 git-dmz01 systemd[1]: [/etc/systemd/system/gitblit_server.service:12] Missing '='.
Sep 01 16:06:22 git-dmz01 sudo[7121]: pam_unix(sudo:session): session closed for user root

content of my file gitblit_server.service:

[Unit]
   Description=gitblit Server CVS
   After=network.target
[Service]
   User=msoadmin
   Type=simple
   WorkingDirectory=/opt/gitblit
   PIDFile=/var/run/gitblit.service.pid
   ExecStartPre=/opt/gitblit/java-proxy-config.sh
   ExecStart=/usr/bin/java -server -Xmx1024M -Djava.awt.headless=true -jar
   /opt/gitblit/gitblit.jar --baseFolder /opt/gitblit/data --dailyLogFile

[Install]
   WantedBy=multi-user.target
Max
  • 113

1 Answers1

2

You are using the wrong answer to create custom services. To start with, custom service files should not be placed within /lib/systemd/system rather you'd use /etc/systemd/system/your_custom_file.service.

Secondly, after creating the service file you'd run systemct daemon-reload to notify systemd about your newly created file. Make sure you've restored SELinux file context using restorecon -RFvv /etc/systemd/system

After the update, the answer is obvious.

[Service]
.....
....
ExecStart=/usr/bin/java -server -Xmx1024M -Djava.awt.headless=true -jar
   /opt/gitblit/gitblit.jar --baseFolder /opt/gitblit/data --dailyLogFile
....

Here, the line that starts with /opt/gitblit/.. is treated as a single line and not part of ExecStart directive which is causing the error. You could simply fix it using a backslash as follows:

ExecStart=/usr/bin/java -server -Xmx1024M -Djava.awt.headless=true -jar \
   /opt/gitblit/gitblit.jar --baseFolder /opt/gitblit/data --dailyLogFile

Finally run:

systemctl daemon-reload && systemctl enable gitblit_server.service