How to Run a ServiceNow MID Server on Apple Silicon Macs

Reece PoulsenReece Poulsen
6 min read

Today, I spent more time than I'd like to admit trying to get a MID Server running on my Apple Silicon Mac. About a year ago, some of my co-workers wrote a blog post, Installing a MID Server on a Mac, which was crucial in helping me get started. However, I had to take a few extra steps to complete the process. So, in an attempt to preserve some knowledge and hopefully help someone else, I thought I would share some of my notes in addition to their original post.

Running a ServiceNow MID Server on an Apple Silicon Mac isn’t officially supported. However, since MacOS is Linux-based, the Linux version of the MID Server is technically compatible. With the help of a JDK, a Tanuki Java Service Wrapper, and a little bit of extra config it is possible. This guide walks you through the entire process step by step.

📢
I am using an M1 Pro MacBook and a PDI on the latest Xanadu release (build tag glide-xanadu-07-02-2024__patch0-07-16-2024). If your instance is on a different release then version numbers for the installed components may change but the idea is generally the same.

Download the Necessary Files

  1. In your ServiceNow instance, navigate to MID Servers > Downloads to download the Linux 64 bit zip file

  2. Download the Amazon Corretto 17 JDK for Apple Silicon arm64 tar zip here: https://corretto.aws/downloads/latest/amazon-corretto-17-aarch64-macos-jdk.tar.gz

What is Amazon Corretto?
It is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that includes performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.
  1. Download the Tanuki Java Service Wrapper version 3.5.51 for Apple Silicon arm64 tar zip file here: https://download.tanukisoftware.com/wrapper/3.5.51/wrapper-macosx-arm-64-3.5.51.tar.gz

What is the Tanuki Java Service Wrapper?
The Tanuki Java Service Wrapper is a tool designed to help manage and control the execution of Java applications as services across various platforms. Its primary function is to act as an intermediary between Java applications and the operating system, ensuring that Java-based services can be reliably run, monitored, and controlled in environments where services need to be constantly available, such as servers.
  1. Once all of these files are downloaded, make sure to extract them into a folder that you won’t lose because we will be coming back to them later

Move Files into the MID Server

💡
Opening your MID Server folder in VSCode makes things a little easier but isn’t necessary. It just helps with moving files around and gives you the ability to run commands in the integrated terminal which will come in handy later.

JDK

  1. Open the MID Server folder in Finder and navigate to the agent directory

  2. Create a new folder called amazon-corretto-17.jdk

  3. In a second Finder window, open the unzipped Amazon Corretto 17 tar folder that you downloaded earlier

  4. Navigate to Contents/Home directory in the Amazon Corretto 17 tar and move all of its contents to the newly created amazon-corretto-17.jdk folder in the MID Server

Service Wrapper

  1. Open the unzipped Tanuki Service Wrapper tar folder that you downloaded earlier

  2. Open the bin folder

  3. Rename the wrapper file in this folder to wrapper-macosx-arm-64

  4. Move this file to the MID Server’s bin folder (mid_server_folder/agent/bin)

  5. Go back to the Tanuki Service Wrapper tar folder

  6. Open the lib folder

  7. Rename the libwrapper.dylib file in this folder to libwrapper-macosx-arm-64.dylib

  8. Move this file to the MID Server’s lib folder (mid_server_folder/agent/lib)

Modify the MID Server Config

  1. In the MID Server folder navigate to the agent/conf directory and open the wrapper-jvm.conf file and replace set.SN_JVM_ARCH=x86-64 with set.SNC_JVM_ARCH=arm-64 . This changes the MID Server’s JVM architecture to use arm instead of x86

  2. In the same MID Server folder from the previous step, agent/conf, open the wrapper-override.conf file and scroll down the External JRE section. Add this line:

     wrapper.java.command=amazon-corretto-17.jdk/bin/java
    

    This tells the MID Server to run its Java commands through the Amazon Corretto 17 JDK rather than the version of Java that you may or may not have installed on your local machine.

  3. In that same file and section add another line:

     wrapper.java.additional.148=-Djdk.lang.Process.launchMechanism=POSIX_SPAWN
    

    This sets the process launch mechanism to use the new posix_spawn method rather than the older and unsupported vfork

    💡
    The .148 in this line is just an index number, if you open the agent/conf/wrapper.conf file you will see around line 114 this text wrapper.java.additional.129=-Djdk.lang.Process.launchMechanism=vfork. Since we are adding contents to the wrapper-override.conf it overrides the values in the original config but only if it has a higher index. The index in the original config is .129 hence the index of .148 in the wrapper override file.
    IMPORTANT: Don’t forget the - in front of Djdk.lang.Pro... its a flag so it has to have a dash in front of it to be a valid Java command!

Create and Configure a MID Server User

  1. Create a new user in ServiceNow for this MID Server. It should have a username, first name, last name, and password (save the credentials, you will need them in the next steps)

  2. Assign the mid_server role to this newly created user

  3. Configure the MID Server to run as your newly created MID Server user

    1. Navigate to agent in the MID Server folder and open the config.xml file

    2. Change the url, username, password, and name elements to reflect your instance and MID Server user

Run the MID Server

  1. In your terminal, navigate to agent in the MID Server folder and run this command (you should only have to run this once so make sure that you do it in the right directory):

     sudo xattr -dr com.apple.quarantine .
    

    Yes the period is important! This command prevents Apple’s security settings from blocking the JDK from running.

  2. Navigate to agent in the MID Server directory and run

     sudo ./start.sh
    

    This command should start your MID Server

  3. Validate the MID Server by going to MID Servers > Servers In your ServiceNow instance and click the validate button. It should go down for a minute and then come back up once the validation is done.

  4. (Optional) If you need to stop your MID Server you can do so by running this command in the agent folder of your MID Server directory

     sudo ./stop.sh
    

Conclusion

If everything went well, your MID Server should be up and running 🎉! Keep in mind that the details of this guide might vary depending on the ServiceNow family release your instance is using. I hope this works for you as it did for me, and if not, I hope it points you in the right direction!

0
Subscribe to my newsletter

Read articles from Reece Poulsen directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Reece Poulsen
Reece Poulsen

Back in my freshman year of college, I was introduced to the world of programming, and it immediately caught my attention. The idea of creating something new with just a little learning and a couple of lines of code fascinated me—it was like discovering a whole new universe of possibilities! Ever since that moment, I've been on a continuous journey to expand my programming knowledge and skills. Now I'm a relatively new software developer on the ServiceNow platform, and I'm eager to explore its potential. Through this blog, I hope to share some of the things I'm learning along the way. Let's dive into the world of ServiceNow together and uncover the tricks and insights that can make a difference for us as developers!