pm2: conflict with ecosystem.config.js
SimonLab opened this issue · 1 comments
I had an issue while using pm2 for deployement:
The master branch already had a ecosystem.config.js
but when I tried to create a new PR this issue appears:
I tried to rebase/merge my branch with master but it was already up to date
I figure out that the issue was due to the git pull
command defined in predeploy
:
module.exports = {
apps: [{
name: "appname",
script: "./bin/www"
}],
deploy: {
// "production" is the environment name
production: {
// SSH key path, default to $HOME/.ssh
key: "./deploy_key",
// SSH user
user: "dev",
// SSH host
host: ["ip-address-host"],
// SSH options with no command-line flag, see 'man ssh'
// can be either a single string or an array of strings
ssh_options: "StrictHostKeyChecking=no",
// GIT remote/branch
ref: "origin/master",
// GIT remote
repo: "git@github.com:repo_app",
// path on the server
path: "/home/dev",
// Pre-setup command or path to a script on your local machine
"pre-setup": "ls -la",
// Post-setup commands or path to a script on the host machine
// eg: placing configurations in the shared dir etc
"post-setup": "ls -la",
// pre-deploy action
"pre-deploy":"git pull",
// "pre-deploy-local": "echo 'This is a local executed command'",
// post-deploy action
"post-deploy": "npm install && pm2 startOrRestart ecosystem.config.js"
},
}
}
To resolve this issue I replace git pull
by git fetch --all; git reset --hard origin/master
. This will force the pre-deploy to get the master version and discard any conflict occuring with the branch.
This solution is working in my case because I only want to deploy the master branch, however I'm not 100% sure why the conflict occurs in the first place.
@SimonLab thanks for opening this issue!
It's a bit of a strange error message considering the file did exist on the branch.
It might be worth opening this issue on the PM2 GitHub: https://github.com/Unitech/pm2/issues
to see if anyone else knows what the cause was.