Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Run Mirth service manually works, running from systemd errs with "No suitable JVM..."

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Run Mirth service manually works, running from systemd errs with "No suitable JVM..."

    I'm trying to configure my Mirth Connect 3.9.0 to restart automatically when my server reboots.


    1. This is my service file (paths are corrects, the configuration validates with $ systemd-analyze verify mirth.service):

    $ nano /usr/lib/systemd/system/mirth.service

    [Unit]
    Description=MirthConnect
    After=network.target

    [Service]
    Type=forking
    User=root
    Group=root
    ExecStart=/opt/mirth/mcservice start
    ExecStop=/opt/mirth/mcservice stop
    TimeoutSec=60

    [Install]
    WantedBy=multi-user.target


    2. Enable and run

    $ systemctl enable mirth

    Created symlink /etc/systemd/system/multi-user.target.wants/mirth.service → /lib/systemd/system/mirth.service.


    $ systemctl start mirth

    ERROR


    $ systemctl status mirth

    ● mirth.service - MirthConnect
    Loaded: loaded (/lib/systemd/system/mirth.service; enabled; vendor preset: enabled)
    Active: failed (Result: exit-code) since Fri 2021-04-09 16:35:49 UTC; 6min ago
    Process: 998 ExecStart=/opt/mirth/mcservice start (code=exited, status=83)

    Apr 09 16:35:49 localhost systemd[1]: Starting MirthConnect...
    Apr 09 16:35:49 localhost mcservice[998]: No suitable Java Virtual Machine could be found on your system.
    Apr 09 16:35:49 localhost mcservice[998]: The version of the JVM must be at least 1.8.
    Apr 09 16:35:49 localhost mcservice[998]: Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.

    Apr 09 16:35:49 localhost systemd[1]: mirth.service: Control process exited, code=exited, status=83/n/a
    Apr 09 16:35:49 localhost systemd[1]: mirth.service: Failed with result 'exit-code'.
    Apr 09 16:35:49 localhost systemd[1]: Failed to start MirthConnect.



    3. Running manually works like a charm

    $ cd /opt/mirth
    $ ./mcservice start

    Starting mcservice


    $ ./mcservice status

    mcservice is running.


    $ netstat -tulpn

    I see Mirth ports are being used by a java process, which is Mirth



    Why does it run OK manually but asks for a JVM from the service?

    I have tested with openJDK 1.8 and 11, same results (manual runs OK, service doesn't).


    Thanks.

  • #2
    echo your path and other env vars to debug in the script.

    mcservice (from mirth) can also override the JVM search sequence, it is commented out at the top of the file.

    Diridium Technologies, Inc.
    https://diridium.com

    Comment


    • #3
      Do you mean changing the mcservice to echo PATH and ENV?

      Should I uncomment something there? Can you point me to the exact lines?

      Thanks.

      Comment


      • #4
        What flavor of Linux are you using?
        Diridium Technologies, Inc.
        https://diridium.com

        Comment


        • #5
          this is ubuntu 19

          Comment


          • #6
            I would guess that when you run this manually, you are not logged in as root? It is good practice to set up the service to run as a user other than root, too.

            Maybe you just need to set that environment variable to point to the java installation. I found this SO answer that describes how to set the variable for your service.

            https://serverfault.com/questions/41...ystemd-service

            Comment


            • #7
              1. please check my first post, it mentions how it's run

              2. yes, it is root user

              3. the env var is set

              Comment


              • #8
                Originally posted by ppazos View Post
                1. please check my first post, it mentions how it's run

                2. yes, it is root user

                3. the env var is set
                What I said is that it is good practice to not run your service as root. You don't show setting the environment variable in your service configuration.

                Comment


                • #9
                  Thanks, even though is not a good practice, this should work right?

                  [email protected]:~# env | grep JAVA
                  JAVA_HOME=/root/.sdkman/candidates/java/current
                  INSTALL4J_JAVA_HOME=/root/.sdkman/candidates/java/11.0.10-open

                  [email protected]:~# java -version
                  openjdk version "11.0.10" 2021-01-19
                  OpenJDK Runtime Environment 18.9 (build 11.0.10+9)
                  OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode)

                  [email protected]:~# $JAVA_HOME/bin/java -version
                  openjdk version "11.0.10" 2021-01-19
                  OpenJDK Runtime Environment 18.9 (build 11.0.10+9)
                  OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode)

                  [email protected]:~# $INSTALL4J_JAVA_HOME/bin/java -version
                  openjdk version "11.0.10" 2021-01-19
                  OpenJDK Runtime Environment 18.9 (build 11.0.10+9)
                  OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode)


                  I also tried to set the INSTALL4J_JAVA_HOME to the same value as JAVA_HOME, but it didn't like the /current since it is a link, but is a link to the /11.0.10-open folder.

                  [email protected]:~# service mcservice start
                  Job for mcservice.service failed because the control process exited with error code.
                  See "systemctl status mcservice.service" and "journalctl -xe" for details.

                  [email protected]:~# service mcservice status
                  ● mcservice.service - LSB: Mirth Connect Service
                  Loaded: loaded (/etc/init.d/mcservice; generated)
                  Active: failed (Result: exit-code) since Fri 2021-05-21 20:21:16 UTC; 9s ago
                  Docs: man:systemd-sysv-generator(8)
                  Process: 3013 ExecStart=/etc/init.d/mcservice start (code=exited, status=83)

                  May 21 20:21:16 localhost systemd[1]: Starting LSB: Mirth Connect Service...
                  May 21 20:21:16 localhost mcservice[3013]: No suitable Java Virtual Machine could be found on your system.
                  May 21 20:21:16 localhost mcservice[3013]: The version of the JVM must be at least 1.8.
                  May 21 20:21:16 localhost mcservice[3013]: Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.

                  May 21 20:21:16 localhost systemd[1]: mcservice.service: Control process exited, code=exited, status=83/n/a
                  May 21 20:21:16 localhost systemd[1]: mcservice.service: Failed with result 'exit-code'.
                  May 21 20:21:16 localhost systemd[1]: Failed to start LSB: Mirth Connect Service.


                  Comment


                  • #10
                    Did you try adding this to the [Service] section of your systemd configuration like described in the SO link I shared? I don't think systemd "logs in" as the user it is running as, so you likely won't have the same environment set up as when you are logged in interactively (and really, don't run as root.)

                    Code:
                    Environment=INSTALL4J_JAVA_HOME=/root/.sdkman/candidates/java/11.0.10-open
                    Last edited by agermano; 08-04-2021, 02:30 PM. Reason: removed unnecessary quotes

                    Comment


                    • #11
                      No, I didn't, can you explain where is that coming from? Is documented anywhere? Thanks.

                      Comment


                      • #12
                        on 20.04, this works:

                        forM.png

                        Diridium Technologies, Inc.
                        https://diridium.com

                        Comment


                        • #13
                          agermano suggested changing the ExecStart to below.

                          [Unit]
                          Description=mirth
                          After=syslog.target

                          [Service]
                          Type=simple
                          RemainAfterExit=yes
                          Environment=PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
                          ExecStart=/root/mirth_connect/mcserver

                          [Install]
                          WantedBy=multi-user.target
                          Diridium Technologies, Inc.
                          https://diridium.com

                          Comment


                          • #14
                            I'd probably still include the INSTALL4J_JAVA_HOME environment variable rather that putting the JRE bin dir in the path. I think that would make it simpler to change out your JRE, especially if you aren't using the system managed version. Having the rest of the path still available could be useful if you have mirth code that shells out.

                            Comment


                            • #15
                              pacmano Can you explain that config file? Why does if have different [Unit] After and [Service] Type

                              Then why the ExecStart is using the mcserver and not the mcservice?

                              In that context, not sure what is the role of mcservice at all.

                              It seems there is lack of documentation of something that is pretty common, I mean, running Mirth as service, and have it start automatically on reboots, etc.

                              Also with mcserver, how can it be stoped with: service mirth stop? There is no ExeStop specified...


                              This is my last test and didn't start with: service mirth start or systemctl start mirth.service

                              What command do you use to start the service?

                              [Unit]
                              Description=MirthConnect
                              After=network.target

                              [Service]
                              Type=forking
                              Environment="INSTALL4J_JAVA_HOME=/root/.sdkman/candidates/java/11.0.10-open"

                              User=root
                              Group=root
                              #ExecStart=/opt/mirth/mcservice start
                              #ExecStop=/opt/mirth/mcservice stop
                              ExecStart=/opt/mirth/mcserver
                              #ExecRestart=/opt/mirth/mcservice restart
                              #Restart=always
                              TimeoutSec=60

                              [Install]
                              WantedBy=multi-user.target

                              Last edited by ppazos; 06-23-2021, 11:35 AM.

                              Comment

                              Working...
                              X