Script running at Server startup

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

0 votes

0 answers

67 views

ANSWER

Can you more details about your event handler?
08/19/2020

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