0

I've a metabase service that I used to manage with systemD. I can successfully start it by invoking it directly on the CLI:

/usr/bin/java -jar -Xmx512m /usr/local/sbin/metabase.jar

But when trying to start it through a systemD service, it get an error:

Jan 14 20:45:59 sd-120866 systemd[1]: Started Metabase.
Jan 14 20:46:01 sd-120866 metabase[15432]: 01-14 20:46:01 #033[1mINFO metabase.util#033[0m :: Loading Metabase...
Jan 14 20:46:03 sd-120866 metabase[15432]: 01-14 20:46:03 #033[1mINFO util.encryption#033[0m :: DB details encryption is DISABLED for this Metabase instance.
Jan 14 20:46:03 sd-120866 metabase[15432]: See http://www.metabase.com/docs/latest/operations-guide/start.html#encrypting-your-database-connection-details-at-rest for more information.
Jan 14 20:46:06 sd-120866 metabase[15432]: #033[31mUnrecognized command: >>#033[0m
Jan 14 20:46:06 sd-120866 metabase[15432]: Valid commands are:
Jan 14 20:46:06 sd-120866 metabase[15432]: api-documentation []
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: help []
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: load-from-h2 [] [h2-connection-string]
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: migrate [direction]
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: profile []
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: reset-password [email-address]
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: version []
Jan 14 20:46:06 sd-120866 metabase[15432]: #011 nil
Jan 14 20:46:06 sd-120866 metabase[15432]: Some other commands you might find useful:
Jan 14 20:46:06 sd-120866 metabase[15432]: java -cp metabase.jar org.h2.tools.Shell -url jdbc:h2:/path/to/metabase.db
Jan 14 20:46:06 sd-120866 metabase[15432]: #011Open an SQL shell for the Metabase H2 DB
Jan 14 20:46:06 sd-120866 systemd[1]: metabase.service: Main process exited, code=exited, status=1/FAILURE
Jan 14 20:46:06 sd-120866 systemd[1]: metabase.service: Unit entered failed state.
Jan 14 20:46:06 sd-120866 systemd[1]: metabase.service: Failed with result 'exit-code'.
Jan 14 20:46:08 sd-120866 systemd[1]: metabase.service: Service hold-off time over, scheduling restart.
Jan 14 20:46:08 sd-120866 systemd[1]: Stopped Metabase.

I don't know what's wrong, all the more that it used to work. Here's the systemD service file:

[Unit]
Description=Metabase

[Service]
ExecStart=/usr/bin/java -jar -Xmx512m /usr/local/sbin/metabase.jar >> /var/log/syslog

Restart=always
RestartSec=1500ms

StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=metabase

[Install]
WantedBy=multi-user.target
Buzut
  • 815
  • 3
  • 10
  • 23

1 Answers1

1

Metabase doesn't know how to interpret the string >> that you provided on the command line. It is interpreting that as a command, but it doesn't appear to actually be a valid command.

It appears you intended to redirect the program's output somewhere. But you can't do that with >> or other shell constructs in systemd, because no shell is being used. Thus it was passed to Metabase as a command line argument.

Rather, you should use StandardOutput= and StandardError= to redirect stdout and stderr, as you already have.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Oh yes, it works. Indeed there's no shell with systemd, I still have some Upstart bad habits… Thank you! – Buzut Jan 15 '18 at 08:16