I'm writing an small application in nodejs.
This app should be executed as windows service (so I can't use electron or others because It should be active even if the user is not logged), and so I have thought to use PM2. It starts and works fine, but my problem, now, are the updates of my NodeJS app.
My app will released to many PC and I don't want update it one by one.
Yes, I have a repository where I can read and so I can create in my app a function where with established interval I go to my repo and pull.
For now I have created, in packages.json of my NodeJs app a scripts command like:
git pull //myrepourl.git origin
And in my index.js a function like:
function updateApp(){
return new Promise((resolve,reject)=>{
exec('cd app_path && npm run prod_update', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
reject();
}
resolve();
});
})
}
setInterval( ()=>{
updateApp();
console.log("------ Updated ---------")
},60*60*1000);
But this way don't convince me because actually my repo is private and then I have to expose my credentials git in app, whithout considering the problem of node_modules.
So are there others way to update a Nodejs app launched with PM2 as Service on Windows?