Problems setting up service on Ubuntu

I have the exact problem on Ubuntu

[Unit]
Description=Metabase server
After=syslog.target
After=network.target

[Service]
WorkingDirectory=/opt/metabase/
ExecStart=/usr/bin/java -jar /opt/metabase/metabase.jar
EnvironmentFile=/etc/default/metabase
User=metabase
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=metabase
SuccessExitStatus=143
TimeoutStopSec=120
Restart=always

[Install]
WantedBy=multi-user.target

I've done everything to the book

@dawoodjee You need to post more details. Which version of Ubuntu? Have you checked the syslogs? Have you tried systemctl status metabase.service ?

Yes:

● metabase.service - Metabase server
   Loaded: loaded (/etc/systemd/system/metabase.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2021-07-06 09:19:11 CAT; 3h 41min ago
  Process: 11645 ExecStart=/usr/bin/java -jar /opt/metabase/metabase.jar (code=exited, status=1/FAILURE)
 Main PID: 11645 (code=exited, status=1/FAILURE)

Jul 06 09:19:10 web-server systemd[1]: metabase.service: Main process exited, code=exited, status=1/FAILURE
Jul 06 09:19:10 web-server systemd[1]: metabase.service: Failed with result 'exit-code'.
Jul 06 09:19:11 web-server systemd[1]: metabase.service: Service hold-off time over, scheduling restart.
Jul 06 09:19:11 web-server systemd[1]: metabase.service: Scheduled restart job, restart counter is at 5.
Jul 06 09:19:11 web-server systemd[1]: Stopped Metabase server.
Jul 06 09:19:11 web-server systemd[1]: metabase.service: Start request repeated too quickly.
Jul 06 09:19:11 web-server systemd[1]: metabase.service: Failed with result 'exit-code'.
Jul 06 09:19:11 web-server systemd[1]: Failed to start Metabase server.```

@dawoodjee Well, that is not the same problem as this topic.
My first guess is either a problem with Java or maybe permissions or the environment variables.
Check the Metabase log - likely /var/log/metabase.log
Check Java version - /usr/bin/java -version

I thought so as well. The Java seems fine and I ran the permission settings like 3 times

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.18.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.18.04, mixed mode, sharing)

Its weird that I have nothing in my logs

@dawoodjee

  1. Post the output of
    sed -nE 's/^PRETTY_NAME="([^"]+)"$/\1/p' /etc/os-release
  2. Run this
    sudo chown syslog:adm /var/log/metabase.log
  3. And try starting the service again and then check the log.

I've run both commands

# sed -nE 's/^PRETTY_NAME="([^"]+)"$/\1/p' /etc/os-release
Ubuntu 18.04.5 LTS
/opt/metabase# sudo systemctl status metabase.service
● metabase.service - Metabase server
   Loaded: loaded (/etc/systemd/system/metabase.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2021-07-06 13:29:49 CAT; 9s ago
  Process: 31126 ExecStart=/usr/bin/java -jar /opt/metabase/metabase.jar (code=exited, status=1/FAILURE)
 Main PID: 31126 (code=exited, status=1/FAILURE)

Jul 06 13:29:49 web-server systemd[1]: metabase.service: Main process exited, code=exited, status=1/FAILURE
Jul 06 13:29:49 web-server systemd[1]: metabase.service: Failed with result 'exit-code'.
Jul 06 13:29:49 web-server systemd[1]: metabase.service: Service hold-off time over, scheduling restart.
Jul 06 13:29:49 web-server systemd[1]: metabase.service: Scheduled restart job, restart counter is at 5.
Jul 06 13:29:49 web-server systemd[1]: Stopped Metabase server.
Jul 06 13:29:49 web-server systemd[1]: metabase.service: Start request repeated too quickly.
Jul 06 13:29:49 web-server systemd[1]: metabase.service: Failed with result 'exit-code'.
Jul 06 13:29:49 web-server systemd[1]: Failed to start Metabase server.

I did most of the installation as root, is there any recommendation against that with metabase?

Also must note that running the jar file works just fine

java -jar metabase.jar

@dawoodjee

Output the log cat /var/log/metabase.log

You have to use root to setup services and install stuff. That's how operating systems works. But the service should run as a non-privileged user. Exactly how it's described in the guide.

/opt/metabase# cat /etc/rsyslog.d/metabase.conf
if $programname == 'metabase' then /var/log/metabase.log
& stop

/opt/metabase# cat /etc/default/metabase
MB_PASSWORD_COMPLEXITY=normal
MB_DB_TYPE=mysql
MB_DB_DBNAME=m
MB_DB_PORT=3306
MB_DB_USER=muser
MB_DB_PASS=password
MB_DB_HOST=localhost
MB_EMOJI_IN_LOGS=true
MB_JETTY_HOST=localhost
MB_JETTY_PORT=3000

@dawoodjee You are not reading what I'm asking. Delete everything and follow the entire guide again:
https://github.com/metabase/metabase/blob/master/docs/operations-guide/running-metabase-on-debian.md

If you want someone else to manage the Metabase setup, then you can use Metabase Cloud:
https://www.metabase.com/pricing/

Hey @flamber

Thank you for your time, I'm sorry I missed a bit here.

Posting extra stuff was my way of trying to give you more context.

Jul  6 13:29:48 localhost metabase[31054]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:29:48 localhost metabase[31074]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:29:49 localhost metabase[31093]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:29:49 localhost metabase[31110]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:29:49 localhost metabase[31126]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:40:02 localhost metabase[667]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:40:02 localhost metabase[683]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:40:02 localhost metabase[701]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:40:03 localhost metabase[721]: Error: Unable to access jarfile /opt/metabase/metabase.jar
Jul  6 13:40:03 localhost metabase[740]: Error: Unable to access jarfile /opt/metabase/metabase.jar```

@dawoodjee Well that clearly says that /opt/metabase/metabase.jar does not have the correct permissions.

Definitely that, pheew!

/etc/nginx/conf.d$ sudo chmod -R 7777 /opt/metabase
/etc/nginx/conf.d$ sudo systemctl start metabase
/etc/nginx/conf.d$ sudo systemctl status metabase
● metabase.service - Metabase server
   Loaded: loaded (/etc/systemd/system/metabase.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-07-06 13:53:28 CAT; 8s ago
 Main PID: 3829 (java)
    Tasks: 20 (limit: 4915)
   CGroup: /system.slice/metabase.service
           └─3829 /usr/bin/java -jar /opt/metabase/metabase.jar

Jul 06 13:53:28 web-server systemd[1]: Started Metabase server.

What would you say is the correct permission for the directory

@dawoodjee No, but if you followed the guide, then you would not need to create global permissions:
https://github.com/metabase/metabase/blob/master/docs/operations-guide/running-metabase-on-debian.md#create-an-unprivileged-user-to-run-metabase-and-give-him-acces-to-app-and-logs

1 Like