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

  • agermano
    replied
    According to https://stackoverflow.com/questions/...rked-downsides and the link from the accepted answer https://www.freedesktop.org/software...an/daemon.html, you should prefer setting the type to simple instead of forking and call mcserver instead of mcservice. As I previously mentioned, this is the way NextGen chose to run the official docker container as well.

    Leave a comment:


  • ppazos
    replied
    I can also confirm my current configuration works as a service: when the server is rebooted, the mirth service is started automatically

    /usr/lib/systemd/system$ cat mirth.service
    [Unit]
    Description=MirthConnect
    After=network.target

    [Service]
    Type=forking
    RemainAfterExit=yes
    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
    TimeoutSec=60

    [Install]
    WantedBy=multi-user.target

    Leave a comment:


  • agermano
    replied
    Thanks balaji1503 and ppazos for the clarification.

    I edited my previous comment to remove the quotes. I had just copied that syntax from the accepted SO answer that I linked.

    Leave a comment:


  • ppazos
    replied
    Thanks balaji1503 I heavily suspect the issue was just about the quotes in the Environment that I was using:

    Environment="INSTALL4J_JAVA_HOME=/root/.sdkman/candidates/java/11.0.10-open"

    I removed them, and left with something very similar to what you have (I wanted to use mcservice not mcserver) and finally it worked!

    So, for the record, this is the right way of specifying the Environment:

    Environment=INSTALL4J_JAVA_HOME=/root/.sdkman/candidates/java/11.0.10-open

    Leave a comment:


  • balaji1503
    replied
    This loop really helped and finally, below Worked!! Note, Java path should be at main folder and not bin folder

    $ cat /usr/lib/systemd/system/mirthconnect.service
    [Unit]
    Description=MirthConnect
    After=network.target

    [Service]
    Type=forking

    User=root
    Group=root

    Environment=INSTALL4J_JAVA_HOME=/app1/java/adoptopenjdk-jre

    ExecStart=/opt/mirthconnect/mcservice start
    ExecStop=/opt/mirthconnect/mcservice stop

    TimeoutSec=60

    [Install]
    WantedBy=multi-user.target
    Last edited by balaji1503; 07-30-2021, 09:30 AM.

    Leave a comment:


  • pacmano
    replied
    ppazos what I posted works with standard standard systemctl/service commands. Try it, you will see mirth start and stop cleanly.

    Leave a comment:


  • agermano
    replied
    mcserver runs in the foreground and is stopped by sending it a TERM or INT (Ctrl-C) signal, so it should be set to simple instead of forking.

    mcservice start forks a process which runs in the background and requires another command to stop the background service.

    You run one or the other. The official docker container runs mcserver.

    Leave a comment:


  • ppazos
    replied
    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.

    Leave a comment:


  • agermano
    replied
    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.

    Leave a comment:


  • pacmano
    replied
    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

    Leave a comment:


  • pacmano
    replied
    on 20.04, this works:

    forM.png

    Leave a comment:


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

    Leave a comment:


  • agermano
    replied
    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

    Leave a comment:


  • ppazos
    replied
    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.


    Leave a comment:


  • agermano
    replied
    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.

    Leave a comment:

Working...
X