YAJSW Suggestion

#1

I found that it was very easy to install metabase on Linux with Yet Another Java Service Wrapper. It has a built in script that creates the wrapper config “wrapper.conf” for you (only requiring minor tweaking), and you can declare all of your environment variables as part of that config. I had it running as a service in maybe 30 minutes as a first time user. I thought it may be helpful information for some people.

#2

Hi @Gatenby32073
Have you seen the documentation about installing Metabase as a service on Debian-based systems? While it’s not perfect, for most, it’ll get them up and running pretty quick:
https://metabase.com/docs/latest/operations-guide/running-metabase-on-debian.html
Could you share your wrapper.conf, just if someone wants to do the same as you?

#3

This was done on a Red Hat server, which is why I didn’t read into the Debian instructions. Unfortunately I can not share that specific config for security reasons. If I can make some time I can attempt the same setup on a Debian based pc I have and write up a brief step by step.

#4

Okay, fair enough :slight_smile:
There’s actually a couple of SystemD setups - currently they’re just PR’s, so they haven’t been implemented, but they will work with minor tweaking.
https://github.com/metabase/metabase/pulls?utf8=✓&q=is%3Apr+systemd

#5

An update: This actually works on a lot of systems, including windows.

Yet Another Java Service Wrapper page, http://yajsw.sourceforge.net/ ,
Which includes full instructions on using the genConfig.sh or genConfig.bat (windows) to generate the base configuration file.

Below is an example of a basic config for metabase (NOTE: This config has metabase run as root)
Examples of setting environment variables are at the end!

#WARNING - Do not modify any of the properties when an application
#using this configuration file has been installed as a service or daemon.
#Please uninstall the service before modifying this file. The
#service must then be reinstalled.

#********************************************************************
#Java Executable Properties
#********************************************************************
#Java Application
#wrapper.java.command=java

#or define conditions for YAJSW searching for a JVM
#currently only valid for windows
#wrapper.java.command.minVersion=1.5
#wrapper.java.command.maxVersion=1.6
#wrapper.java.command.jreOnly=true
#wrapper.java.command.jdkOnly=true
#wrapper.java.command.preferJre=true
#wrapper.java.command.preferJdk=true
#wrapper.java.command.javaw=true

#copy java.exe to /java__nnnn.exe
#wrapper.java.customProcName=

#********************************************************************
#working directory
#********************************************************************
wrapper.working.dir=/usr/local/lib/metabase

#Java Main class.
#YAJSW: default is “org.rzo.yajsw.app.WrapperJVMMain”
#DO NOT SET THIS PROPERTY UNLESS YOU HAVE YOUR OWN IMPLEMENTATION
#wrapper.java.mainclass=

#********************************************************************
#tmp folder
#yajsw creates temporary files named in_… out_… err_… jna…
#per default these are placed in jna.tmpdir.
#jna.tmpdir is set in setenv batch file to /tmp
#********************************************************************
wrapper.tmp.path = ${jna_tmpdir}

#********************************************************************
#Application main class or native executable
#One of the following properties MUST be defined
#********************************************************************

#Java Application main class
wrapper.java.app.mainclass=

#or jar file
#wrapper.java.app.jar=

#or groovy script file
#wrapper.groovy=

#or a native executable
#wrapper.image=

#********************************************************************
#Application process cpu priority and affinity
#********************************************************************

#Process priority: LOW, BELOW_NORMAL, NORMAL, ABOVE_NORMAL, HIGH
#wrapper.priority

#CPU affinity of the process. this is a bit-array representing the cpus
#wrapper.affinity=

#********************************************************************
#Application Account
#Equivalent to Posix sudo or windows runas
#Note Posix:
#<user> (note: use \ in configuration file).
#If no group is configured default group of the user is used
#********************************************************************
#wrapper.app.account=
#wrapper.app.password=

#********************************************************************
#Java/Groovy Application Properties
#********************************************************************

#Java Classpath (include wrapper.jar) Add class path elements as
#needed starting from 1
#YAJSW: all libs required by YAJSW are in the manifest of the wrapper.jar -> only classpath of your application is required
#wrapper.java.classpath.1=

#Java Library Path
#YAJSW: required dll are encapsulated in jar files -> only library path of your application required
#wrapper.java.library.path.1=…/lib

#Java Additional Parameters
#wrapper.java.additional.1=

#Initial Java Heap Size (in MB)
#alternative for wrapper.java.additional.=-Xms
#wrapper.java.initmemory=3

#% of total RAM
#wrapper.java.initmemory.relative=10

#Maximum Java Heap Size (in MB)
#alternative for wrapper.java.additional.=-Xmx
#wrapper.java.maxmemory=64

#% of total RAM
#wrapper.java.maxmemory.relative=30

#JSW requires that main class is set as app.parameter property
#YAJSW: to specify the main class please use wrapper.java.app.mainclass=

#********************************************************************
#Application environment properties.
#********************************************************************
#Adds an environment to the application
#wrapper.app.env.=

#********************************************************************
#Wrapper Logging Properties
#********************************************************************
#Format of output for the console. (See docs for formats)
#wrapper.console.format=PM

#Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO

#Log file to use for wrapper output logging.
wrapper.logfile=${wrapper_home}/log/wrapper.log

#Format of output for the log file. (See docs for formats)
#wrapper.logfile.format=LPTM

#Log Level for log file output. (See docs for log levels)
#wrapper.logfile.loglevel=INFO

#Maximum size that the log file will be allowed to grow to before
#the log is rolled. Size is specified in bytes. The default value
#of 0, disables log rolling by size. May abbreviate with the ‘k’ (kB) or
#‘m’ (mB) suffix. For example: 10m = 10 megabytes.
#If wrapper.logfile does not contain the string ROLLNUM it will be automatically added as suffix of the file name
wrapper.logfile.maxsize=10m

#Maximum number of rolled log files which will be allowed before old
#files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=10

#Controls the roll mode of the log file
#possible values: DATE, WRAPPER, JVM
#If DATE is set wrapper.logfile should contain the string YYYYMMDD
#If DATE is set and wrapper.logfile.maxsize is set the log file will be rolled by size and date
#If DATE is set and wrapper.logfile.maxfiles older files rolled by size or date are deleted
#wrapper.logfile.rollmode=DATE

#********************************************************************
#Application Console Properties
#********************************************************************
#Indicate if console of the application is visible.
#wrapper.console.visible=false

#Title to use when running as a console
wrapper.console.title=metabase

#********************************************************************
#Wrapper Windows Service and Posix Daemon Properties
#********************************************************************
#Name of the service
wrapper.ntservice.name=metabase

#Display name of the service
wrapper.ntservice.displayname=metabase

#Description of the service
wrapper.ntservice.description=metabase

#Service dependencies. Add dependencies as needed starting from 1
#wrapper.ntservice.dependency.1=

#Mode in which the service is installed. AUTO_START or DEMAND_START
#wrapper.ntservice.starttype=AUTO_START

#Allow the service to interact with the desktop.
#wrapper.ntservice.interactive=false

#wrapper service user. only for windows. on *nix system this is root.
#see also wrapper.app.account
#wrapper.ntservice.account=
#wrapper.ntservice.password=

#********************************************************************
#Wrapper Posix Daemon Properties
#********************************************************************
#Directory in which to create and execute daemon init scripts. Default: /etc/init.d
#wrapper.daemon.dir =

#Directory where to store the wrapper pid file. Default: /var/run
#wrapper.daemon.pid.dir =

#Directory in which to create K… and S… links.
#Default: <wrapper.daemon.dir>/rcX.d
#For Ubuntu set to /etc/rcX.d
#The following grooy script should set it correctly for most distros
wrapper.daemon.run_level_dir=${if (new File(’/etc/rc0.d’).exists()) return ‘/etc/rcX.d’ else return ‘/etc/init.d/rcX.d’}

#Setting the runlevels and priorities for automatic startup and stop of the daemon.
#Similar syntax as the update_rc.d command
#Default: equivalent to default of update_rc.d
#wrapper.daemon.update_rc = start 20 2 3 4 . start 30 5 . stop 80 0 1 6

#********************************************************************
#Wrapper System Tray Properties
#********************************************************************
#enable system tray
wrapper.tray = false

#TCP/IP port. If none is defined multicast discovery is used to find the port
#Set the port in case multicast is not possible.
#wrapper.tray.port = 15002

#icon file to use, per default a console icon is used
#wrapper.tray.icon=

#********************************************************************
#Exit Code Properties
#Restart on non zero exit code
#********************************************************************
wrapper.on_exit.0=SHUTDOWN
wrapper.on_exit.default=RESTART

#********************************************************************
#Posix Signal Properties
#Restart on non 9 signal code
#********************************************************************
wrapper.on_signal.9=SHUTDOWN
wrapper.on_signal.default=RESTART

#********************************************************************
#Trigger actions on console output
#********************************************************************
#On Exception show message in system tray
wrapper.filter.trigger.0=Exception
wrapper.filter.script.0=scripts/trayMessage.gv
wrapper.filter.script.0.args=Exception

#********************************************************************
#Wrapper JMX

#connect using for example jconsole per remote access using the url

#service:jmx:rmi:///jndi/rmi://localhost:1099/server

#eventl. change port and server name
#********************************************************************
#Enable wrapper JMX
#wrapper.jmx = true

#JMX RMI port. default is 1099
#wrapper.jmx.rmi.port =

#JMX RMI credentials
#mandatory if accessing from remote server
#wrapper.jmx.rmi.user =
#wrapper.jmx.rmi.password =

#********************************************************************
#Wrapper timeouts
#********************************************************************
#Number of seconds to allow between the time that the Wrapper starts the application
#and the application logon to the wrapper.
#Default: 30 seconds
#wrapper.startup.timeout =

#Number of seconds to allow between the time that the Wrapper asks the application to shutdown and the time that the JVM shuts down.
#Default: 30 seconds
#wrapper.shutdown.timeout =

#Number of seconds the wrapper waits for a ping message from the java application.
#If no heart beat is received within a timeout the wrapper assumes that the application
#is non responsive and will restart it.
#Default: 30 seconds
#wrapper.ping.timeout =

#********************************************************************
#genConfig: further Properties generated by genConfig
#********************************************************************
placeHolderSoGenPropsComeHere=
wrapper.java.app.jar = /usr/local/lib/metabase/metabase.jar
wrapper.java.command = java

#Example System Variables, UNCOMMENT/ UPDATE VALUES TO USE
#wrapper.app.env.mb_db_type = mysql
#wrapper.app.env.mb_db_dbname = metabase
#wrapper.app.env.mb_db_port = 3306
#wrapper.app.env.mb_db_user =
#wrapper.app.env.mb_db_password =
#wrapper.app.env.mb_db_host = localhost