Skip to main content

run API adapter as unattended (or service) on linux

NChid-1960
Original Poster

Just managed to successfully run the API adapter on linux at the command prompt. Looking for a way to install it & run it as a windows service-like. that will restart on reboot or failure.

 

Any pointers?

 

Thanks,

Nic

Join the conversation

You need to be logged in to reply to this post and participate in the Geotab Community discussions.

2 Replies

EishiFUN
Geotabber

Hello @NChid-1960​ ,

 

Thank you for asking your question in our community. I wanted to let you know I have contacted our SDK team to get their help here. I will let you know what I hear from them as soon as I do or have one of them jump in here.

 

Thank you for your patience while I look into this. Feel free to reach out with any other questions you may have in the meantime. We are here to help.

 

Have a good one!

Eishi FUN

EishiFUN
Geotabber

Hey @NChid-1960​  I got some comments from our team I wanted to share with you about this: In Linux, I believe you'd want to setup a Cron job to launch the application. Launching on reboot should be easy. But you'd need to put some sort of monitoring process in place to determine if/when the application crashes. That might include monitoring the running processes to see if the API Adapter stops, or looking at the log file. In the event of a crash, someone should take a look at the logs anyhow as the crash may be due to an unhandled exception that could just keep repeating.

 

The API Adapter already has resilience mechanisms in place to allow it to handle transient exceptions such as loss of connectivity to MyGeotab or the adapter database, timeouts, transaction failures requiring retries, etc. So crashes should not be a regular issue.

 

I also got some advice from Gemini that may be helpful here:

From Gemini

In Linux, the equivalent of a Windows service is a daemon. These are processes that run in the background, typically without direct user interaction, and provide services to other applications or the system itself.

Here's how you achieve the same persistence and automatic booting behavior in Linux:

1. Systemd (Modern Linux Systems)

Systemd is the most common init system and service manager in modern Linux distributions. It provides a robust way to manage services, including automatic startup, restart on failure, and dependency management.

  • Create a systemd service file: Define a .service file in /etc/systemd/system/ describing your application, how to start it, and its dependencies.
  • Enable and start the service: Use systemctl enable to ensure the service starts at boot and systemctl start to start it immediately.

2. Init Scripts (Older Linux Systems)

On older systems that don't use systemd, init scripts located in /etc/init.d/ or similar directories are used.

  • Create an init script: This script will contain commands to start, stop, and restart your application.
  • Configure the script to run at boot: Use tools like chkconfig or update-rc.d to link the script to the appropriate runlevels.

3. Other Process Supervisors

Besides systemd and init scripts, there are other process supervisors available:

  • Supervisor: A popular process control system that monitors and manages processes.
  • nohup: A command that allows a process to continue running even after the user logs out.
  • screen/tmux: Terminal multiplexers that allow you to create persistent sessions, keeping processes running even if the connection is interrupted.

Key Concepts for Persistence:

  • Process Monitoring: The init system or process supervisor monitors the daemon and automatically restarts it if it crashes.
  • Boot Sequencing: The daemon is configured to start automatically during the system boot process.
  • Logging: Daemons often write log messages to files, making it easier to diagnose problems.

Example (Systemd):

Let's say you have an application called myapp. You would create a file named myapp.service in /etc/systemd/system/ with content similar to this:

Ini, TOML

[Unit] Description=My Application After=network.target [Service] ExecStart=/usr/bin/myapp Restart=always [Install] WantedBy=multi-user.target

Then, you would enable and start the service:

Bash

systemctl enable myapp.service systemctl start myapp.service

This ensures that myapp will start automatically at boot and restart if it crashes.

Remember to adjust the paths and commands according to your specific application. If you need more detailed instructions or have a specific application in mind, feel free to ask!

 

Still have questions?