Error starting metabase as Debian service

Hello,

I'm recieving the below erro while starting the metabase service

× metabase.service - Metabase server
     Loaded: loaded (/etc/systemd/system/metabase.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2023-12-09 23:04:58 EET; 2s ago
    Process: 2868026 ExecStart=/usr/bin/java -jar /home/apple/metabase/metabase.jar (code=exited, status=200/CHDIR)
   Main PID: 2868026 (code=exited, status=200/CHDIR)
        CPU: 4ms

Dec 09 23:04:58 nshape-production systemd[1]: metabase.service: Scheduled restart job, restart counter is at 5.
Dec 09 23:04:58 nshape-production systemd[1]: Stopped Metabase server.
Dec 09 23:04:58 nshape-production systemd[1]: metabase.service: Start request repeated too quickly.
Dec 09 23:04:58 nshape-production systemd[1]: metabase.service: Failed with result 'exit-code'.
Dec 09 23:04:58 nshape-production systemd[1]: Failed to start Metabase server.

Java version: openjdk 11.0.21 2023-10-17
No logs produced in: /var/log/metabase.log
OS: Ubuntu 22.04.1 LTS

P.S. apple is the ubuntu user name, just in case name will do some confusion, regrdless of the name :smiley:
Thanks,
Mostafa

please post metabase logs

No logs in the service log file as mentioned in the post
That's why I couldn't find any traces

I think ChatGPT might have found the problem -- the status = 200/CHDIR. Not sure if other stuff applies here, but try it and let me know how it went:

The error you're encountering is a status=200/CHDIR error, which suggests that the service is failing because it cannot change into the working directory specified in your systemd service file. This can occur when the directory doesn't exist, the user running the service doesn't have the proper permissions to access it, or a similar issue related to the filesystem.

Here's how you can troubleshoot this problem:

  1. Check the Directory Exists: Ensure that the directory /home/apple/metabase/ exists and that the Metabase JAR is indeed located there.
  2. Correct Permissions: Verify that the user under which the systemd service is running has appropriate permissions to read the Metabase JAR file and execute it.
  3. Check Service Definition: Inspect /etc/systemd/system/metabase.service to ensure that there are no typos and that all paths are correct. Make sure that the User= directive is set to the correct user if it's meant to be run as apple.
  4. Validate Permissions on the Directory: Verify that the user apple (or the user specified in the service file) has the necessary permissions to access the directory and files. You can do this using the following commands:
sudo -u apple ls /home/apple/metabase/

If the user cannot access that directory, you may need to change the permissions using chown and chmod commands.
5. Check for SELinux/AppArmor: If your system is running SELinux or AppArmor, they may be preventing systemd from changing the directory to the one specified in the service file. Make sure that the security context is correct or that the necessary allowances are made in your security policies.
6. Restart systemd Daemon: If you've made changes to the service file, remember to reload the systemd manager configuration with:

sudo systemctl daemon-reload
  1. Try Starting the Service Manually: Try running the java command from the terminal as the apple user to see if there are any immediate errors:
sudo -u apple java -jar /home/apple/metabase/metabase.jar
  1. Service Restart: Attempt to start the service again and observe any errors:
sudo systemctl start metabase.service
  1. Check System Logs: Since the /var/log/metabase.log is not being populated, you might want to check the system journal for error messages:
journalctl -u metabase.service

Adjust the paths and user names as necessary to align with your system's configuration. Take corrective action based on the output of these checks.

Please proceed with caution and ensure that you are comfortable with these commands or have a system administrator validate the changes. A misconfiguration might lead to other services being affected.

Hello,

Many thanks, it worked
The parent directory wasn't having execute permission