Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to check runModes without system console access. is there any way

Avatar

Level 2

i don't have system console access for few environments . i  want to check runModes please help me. how to check?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @gmahendra ,

The slingSettingsService service is deprecated. It's never recommended you use a deprecated code. You can check this: https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/2476 

 

Since it was very necessary in some situations we can write a custom simple code for this.

In your OSGI config file create something like this.

Sady_Rifat_0-1687764809959.png

 

Maybe you already have some. You can check how you read it from OSGI config: https://medium.com/@toimrank/aem-r6-annotation-57514f7e9838 

 

For this, in your config file just add an extra field 

 

system.runmode=author/publish
system.instance=prod/stage

 

And finally, in your Java class Inject your service and get the run mode by calling the function.

 

Hope you understand this custom solution and why I recommended you for this custom one.

View solution in original post

4 Replies

Avatar

Community Advisor

hello @gmahendra 

 

If you possibly have access to the server via terminal, please try executing "ps -ef|grep java"

 

Look for runmode info in output.


Aanchal Sikka

Avatar

Community Advisor

Hi,

You can get the runmodes in sightly by a sling model 

 

@PostConstruct
public void init() {
String runModes = slingSettingsService.getRunModes().toString();
}

or check below link

https://gist.github.com/gabrielwalt/278f8cee870aac7ec619

Hope this helps!

Avatar

Community Advisor

Hello @gmahendra - 

 

>> If you are using AEM as a cloud service, here are two approaches which you can opt to identify the run modes for a given environment : 

 

1. Adobe Admin Console: Access the Adobe Admin Console (https://[environment-name].adobeioruntime.net/admin), which provides a web-based interface to manage your AEMaaCS instances. Within the Admin Console, navigate to the "Properties" section of your AEM environment. There, you should be able to find the active run modes listed.

 

2. The Programmatic way : [both AEM as cloud service & on-premise]

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;

import org.apache.sling.settings.SlingSettingsService;

@Component(service = MyComponent.class)
public class MyComponent {

    @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
    private SlingSettingsService slingSettingsService;

    public void activate() {
        String[] runModes = slingSettingsService.getRunModes();
        // Process the run modes
    }
}

 

 

 

Avatar

Correct answer by
Community Advisor

Hello @gmahendra ,

The slingSettingsService service is deprecated. It's never recommended you use a deprecated code. You can check this: https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/2476 

 

Since it was very necessary in some situations we can write a custom simple code for this.

In your OSGI config file create something like this.

Sady_Rifat_0-1687764809959.png

 

Maybe you already have some. You can check how you read it from OSGI config: https://medium.com/@toimrank/aem-r6-annotation-57514f7e9838 

 

For this, in your config file just add an extra field 

 

system.runmode=author/publish
system.instance=prod/stage

 

And finally, in your Java class Inject your service and get the run mode by calling the function.

 

Hope you understand this custom solution and why I recommended you for this custom one.