cancel
Showing results for 
Search instead for 
Did you mean: 

Script running at Server startup

Mark_Lumsden
Champ in-the-making
Champ in-the-making

Hi, I am testing automation and have created a script that I am using for testing

function run(input, params) {

Console.log("Creating NEWDOC");
var root = Repository.GetDocument(null, {
    "value" : "/"
});
var newDoc = Document.Create(root, {
    "type" : "File",
    "name" : "newDoc",
    "properties" : {
        "dc:title" : "NEWDOC",
        "dc:description" : "This is a new NEWDOC."
    }
});

return newDoc;

}

However, before I create an event handler to run the script, if I save the script and restart the server which is connected to the project, the script runs twice. Basically, after a server restart, I have 2 new NEWDOCs in root (using nuxeoctl restart). Is this expected behaviour? I expected the script only to run once, and only each time an appropriately configured Event Handler ran. Here are the console.logs:

2020-08-17T15:11:17,186 INFO [http-nio-0.0.0.0-8080-exec-5] [org.nuxeo.runtime.reload.ReloadComponent] After start/resume component manager 2020-08-17T15:11:17,186 INFO [http-nio-0.0.0.0-8080-exec-5] [org.nuxeo.runtime.reload.ReloadComponent] Start running deployment preprocessor 2020-08-17T15:11:17,319 WARN [Nuxeo-Work-default-3:1148014024172349.1676155507] [org.nuxeo.automation.scripting.helper.Console] [LOG] Creating NEWDOC 2020-08-17T15:11:17,344 WARN [Nuxeo-Work-default-3:1148014024172349.1676155507] [org.nuxeo.automation.scripting.helper.Console] [LOG] Creating NEWDOC 2020-08-17T15:11:18,511 INFO [http-nio-0.0.0.0-8080-exec-5] [org.nuxeo.runtime.reload.ReloadComponent] Deployment preprocessing done 2020-08-17T15:11:18,511 INFO [http-nio-0.0.0.0-8080-exec-5] [org.nuxeo.runtime.reload.ReloadComponent] Before reload runtime properties 2020-08-17T15:11:18,512 INFO [http-nio-0.0.0.0-8080-exec-5] [org.nuxeo.runtime.reload.ReloadComponent] After reload runtime properties

Regards, Mark

2 REPLIES 2

Gregory_Carlin
Elite Collaborator
Elite Collaborator

Can you more details about your event handler?

Mark_Lumsden
Champ in-the-making
Champ in-the-making

Hi Gregory, I created a more specific event handler and I resolved the problem. Thanks Mark

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.