vmarchaud / pm2-githook Goto Github PK
View Code? Open in Web Editor NEWreceive webhook from github/gitlab and ask pm2 to reload the application for you
License: MIT License
receive webhook from github/gitlab and ask pm2 to reload the application for you
License: MIT License
The function gracefulReload
no longer exists.
Line 147 in 9774c8b
I think this function is merged with reload
.
See: Unitech/pm2#4426
In the handler for HTTP, X-Forwarded-For
is implicitly trusted. If the pm2 app is exposed directly to the internet, someone can inject their own value into the header, bypassing the bitbucket IP check. Please make a config option that is disabled by default for using the header when running reverse-proxies.
I think the code is intended to use pm_cwd
as a current working directory if targetApp.cwd
is not specified.
Line 129 in 9774c8b
But execOptions
is not updated in this process, so an unintended directory is used as a current working directory on preHook and postHook.
I think the easiness solution is adding execOptions.cwd = targetApp.cwd;
after updating targetApp.cwd
.
Is there any way to use pm2-githook with AWS CodeCommit?
hi,
thanks for this idea but there is a problem.
I have installed this last 1.11 version on a windows 10 pc
pm2 runs well , but this module restarts with errors in loop : here is the error log attached (if you let it 2 mn, it becomes huge)
pm2-githook-error.log
thanks !
Hi, I'm using this module and I think it's amazing.
However I'm running in troubles, because it doesn't support github branches, so every push event on github runs all build tasks, overloading my server. As an example, last week I deleted many useless branch on my repo and the hook was dispatch for each delete, because a branch deletion is considered a push event for github, and my server got down.
I took a look in github webhook documentation and I saw that they send a payload field with the branch that was updated.
Can I submit a pull request with a new option to support github branches?
Thanks.
I'm getting this error whenever I push something to my repo:
TypeError: Cannot read property 'length' of null
at Worker.processRequest (/root/.pm2/node_modules/pm2-githook/index.js:101:17)
at IncomingMessage.<anonymous> (/root/.pm2/node_modules/pm2-githook/index.js:88:10)
at emitNone (events.js:67:13)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:923:12)
at nextTickCallbackWith2Args (node.js:458:9)
at process._tickDomainCallback [as _tickCallback] (node.js:413:17)
TypeError: Cannot read property 'length' of null
at Worker.processRequest (/root/.pm2/node_modules/pm2-githook/index.js:101:17)
at IncomingMessage.<anonymous> (/root/.pm2/node_modules/pm2-githook/index.js:88:10)
at emitNone (events.js:67:13)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:923:12)
at nextTickCallbackWith2Args (node.js:458:9)
at process._tickDomainCallback [as _tickCallback] (node.js:413:17)
logs "Successfuly pulled application api" but doesn't pull. Not sure what can be wrong with it. node v12.10.0
Hello,
I recently got some cases where my prehook script or reload would fail and I didn't notice until taking a look into the logs.
For a successful reload I added a webhook into my posthook which notifies me once the redeploy was successfull.
I would love having that ability in case of an failure as well. I was thinking about adding a third hook to the configuration which gets executed when an error gets catched.
Are you planning on adding that feature?
If not I would just create a pull request and add it myself.
Then you can decide if you want to merge it into your version as well.
Kind regards,
Marc
Can we get some better examples of how to use this? trying to use with github and a branch but can't seem to get it working. have it running on port 5010 which i have a nginx reverse proxy in front of. Current config for an app is below:
{"http://localhost:5000/CLM.ME - DEV": {"secret": "XXXXXXXX", "prehook": "npm install", "posthook": "echo done", "service": "github" }}
is the app name correct asuming its CLM.ME - Dev as the name on PM2? how to set the branch?
I'm getting this whenever I push something to my repo:
[2017-05-02T02:50:15.023Z] Received valid hook for app thegifmachine
[2017-05-02T02:50:15.064Z] Successfuly pulled application thegifmachine
Error: spawn eval ENOENT
at exports._errnoException (util.js:907:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:189:32)
at onErrorNT (internal/child_process.js:355:16)
at nextTickCallbackWith2Args (node.js:458:9)
at process._tickDomainCallback [as _tickCallback] (node.js:413:17)
Server is ready and listen on port 8080
Basically it pulls but fails when restarting, I guess. Also, do I need to add something to my code in order to allow Graceful Reloads?
In GitHub webhook, ref
field does not start with /
such as
{
"ref": "refs/heads/v2",
...
}
Line 279 in 9774c8b
var regex = new RegExp('/refs/heads/' + targetApp.branch)
should be
var regex = new RegExp('refs/heads/' + targetApp.branch)
Example: https://docs.github.com/en/rest/git/refs#list-matching-references
Is it possible to use bitbucket repo to trigger hooks?
I get "OK" response if I just trigger URL with browser or bitbucket hook but no rebuild happens
Bonjour,
I have some time to go deeper in my githook config and solve the problems on my Windows serveur .
When Github deliver a webhook, pm2 githook receives it but have an error you can see in pm2 monitor :
pm2-githook > [2022-06-30T12:09:47.072Z] Received valid hook for app myapp-v2│ ││ pm2-githook > [2022-06-30T12:09:47.784Z] An error has occuring while processing app apiv2 │ ││ pm2-githook > Error: Command failed: cd 'C:\sitesc\serveurapi-v2/';LC_ALL=en_US.UTF-8 git │ ││ pm2-githook > La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte. │ ││ pm2-githook > at ChildProcess.exithandler (node:child_process:399:12) │ │ ││ pm2-githook > at ChildProcess.emit (node:events:520:28) │ │ ││ pm2-githook > at ChildProcess.emit (node:domain:475:12) │ │ ││ pm2-githook > at maybeClose (node:internal/child_process:1092:16) │ │ ││ pm2-githook > at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) { │ │ ││ pm2-githook > killed: false, │ │ ││ pm2-githook > code: 1, │ │ ││ pm2-githook > signal: null, │ │ ││ pm2-githook > cmd: "cd 'C:\\sitesc\\serveurapi-v2/';LC_ALL=en_US.UTF-8 git config --get │ │ ││ pm2-githook > }
in the ecosystem.json , for this app , I have put :
`
module.exports = {
apps : [{
name : "apiv2",
script : "./apiv2.js",
cwd: "/sitesc/serveurapi-v2",
watch: true,
env: {
NODE_ENV: "production",
PORT: "8082",
},
max_restarts: 10,
},
...
`
I do not understand where this path syntax is coming from ! Why the "c:" is added? (It is on c:) , why the "'" are added, and the "//" !!
thank you !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.