How to check runModes without system console access. is there any way | Community
Skip to main content
Level 2
June 25, 2023
Solved

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

  • June 25, 2023
  • 4 replies
  • 2326 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sady_Rifat

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.

 

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.

4 replies

aanchal-sikka
Community Advisor
Community Advisor
June 25, 2023

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
Ravi_Pampana
Community Advisor
Community Advisor
June 25, 2023

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!

Tanika02
Level 7
June 25, 2023

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 } }

 

 

 

Sady_Rifat
Community Advisor
Sady_RifatCommunity AdvisorAccepted solution
Community Advisor
June 26, 2023

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.

 

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.