Running Charon-PAR as a Service

Contents

General Information

Charon-PAR can be started as a service manually and automatically then the Charon host system boots. The service can be stopped manually or automatically when the host system shuts down.

Please note: each instance of Charon-PAR must be started in a separate directory because certain files (SSTORAGE.DAT, NVOLATILE.DAT, UA_SSTORAGE.DAT, and console.dat) will always be created in the current working directory of the emulator instance. Starting multiple emulator instances in the same directory will lead to errors due to file locking problems.

Important points to note when when starting and stopping a Charon-PAR service:

  • Only start Charon-PAR and the guest system automatically, if the guest system and guest system applications can be brought up in unattended mode.  Before setting up a service for automatic start, review your system to verify it is suitable for this type of configuration.
  • Stopping a Charon-PAR service does not include a clean shut-down of the guest operating system. The guest operating system must be shut down cleanly before the Charon-PAR service is stopped because stopping the service is the equivalent of pulling the power plug. Failing to shut down the operating system cleanly can lead to data corruption, data loss, and even an unbootable guest system. Contact Stromasys or your Stromasys VAR if you require additional information.
  • Only activate Charon-PAR as a service during system boot once the correct functioning of all guest system services has been tested manually and a procedure for a clean guest system shutdown has been tested and put in place.
  • When starting Charon-PAR as a service automatic boot of the guest operating system may also be required. Please refer to Guest System Autoboot for more information.
  • When starting Charon-PAR as a services, you have to manually start the terminal emulator to connect to the console serial port (e.g., PuTTY).

Configuring a systemd Service

The Charon-PAR installation kit contains a sample systemd service file. This file can be modified and installed as a systemd service.

Installing and Testing a Charon-PAR systemd Service

  • Ensure that all paths in your Charon-PAR file are absolute paths.
  • Test your Charon-PAR configuration manually until satisfied that it is working correctly and your guest operating system services start as expected.
  • Copy /opt/charon/bin/charon-par.service to a local file. For example: <guest-name>.service
  • Adapt the service file to contain the correct paths to the Charon-PAR executable (/opt/charon/bin/charon-par) and the Charon-PAR configuration file. If you edit the file after it has been copied to the systemd directory, use systemctl daemon-reload to activate the changes.
  • Copy the service file to /etc/systemd/system.
  • Test a manual start of the service:
    # systemctl start <guest-name>
  • Check the status of the service:
    # systemctl status <guest-name>
  • Shut down the guest operating system if running.
  • Test a manual stop of the service:
    # systemctl stop <guest-name>
  • If everything worked as expected, enable the service for automatic startup:
    # systemctl enable <guest-name>

Please note: The console log output of a service is redirected to journalctl.


The following example shows the content of a service file, starting  the service, and checking the status:

Sample service file

$ cat myguest.service

[Unit]
Description="Charon emulator service"
After=syslog.target network.service aksusbd.service
Wants=aksusbd.service

[Service]
Type=forking
ControlGroup=cpu:/
WorkingDirectory=/opt/charon/log
PIDFile=/var/run/myguest.pid
ExecStart=/opt/charon/bin/charon-par -f /Stromasys/Charon-PAR/myguest/myguest.cfg --daemon --pidfile /var/run/myguest.pid

[Install]
WantedBy=multi-user.target

Starting the service

# systemctl start myguest


Service status

$ systemctl status myguest

● myguest.service - "Charon emulator service"
Loaded: loaded (/etc/systemd/system/myguest.service; disabled; vendor preset: d>
Active: active (running) since Fri 2020-03-20 12:03:09 CET; 17s ago
Process: 514524 ExecStart=/opt/charon/bin/charon-par -f /Stromasys/Charon-PAR/myguest/>
Main PID: 514528 (charon-par)
Tasks: 78 (limit: 76997)
Memory: 4.2G
CPU: 1.612s
CGroup: /system.slice/myguest.service
└─514528 /opt/charon/bin/charon-par -f /Stromasys/Charon-PAR/myguest/myguest.cfg

<lines removed>

Stopping and Disabling a systemd Service

To stop and disable the Charon-PAR systemd service perform the following steps:

  • Shut down the guest operating system if running.
  • Stop the service:
    # systemctl stop <guest-name>
  • Disable the service:
    # systemctl disable <guest-name>




© Stromasys, 1999-2024  - All the information is provided on the best effort basis, and might be changed anytime without notice. Information provided does not mean Stromasys commitment to any features described.