Restart module in a Script or in Command Line scripts

Wanted to comment with a solution here.
First steps are getting the module ID that needs to be reset.

#this can be removed once the ID is known
#start a logger to get to get the IDs of the installed modules, this will output to the gateway logs
logger = system.util.getLogger("myLogger")
#this will print all the 
results = system.util.getModules()
for row in range(results.rowCount):
	names = results.getValueAt(row, "Id")
	logger.info(names)

From this the following script can be used to reset the module. This has to be run somewhere that is gateway scoped for scripting.

#Import Java Libraries
import java.util

#Import Inductive Libraries
from com.inductiveautomation.ignition.gateway import IgnitionGateway
from com.inductiveautomation.ignition.gateway.model import ModuleManager
	
#Instantiate Gateway and Module Manager
IGW = IgnitionGateway.get()
moduleManager = IGW.getModuleManager()

#Declare the  module ID as a string
moduleID = 'MODULE ID FROM LOGS HERE'
#Reset the module
moduleManager.restartModule(moduleID)
1 Like