Giter Club home page Giter Club logo

pm2-githook's People

Contributors

capaci avatar craftycram avatar desaroger avatar eywek avatar mhmdrza avatar vmarchaud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pm2-githook's Issues

Cannot read property 'length' of null

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)

Github branch support

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.

An example of payload sent:
image

Can I submit a pull request with a new option to support github branches?

Thanks.

Pulling but not reloading

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?

Current working directory is incorrect if targetApp.cwd is not specified.

I think the code is intended to use pm_cwd as a current working directory if targetApp.cwd is not specified.

targetApp.cwd = apps[0].pm_cwd ? apps[0].pm_cwd : apps[0].pm2_env.pm_cwd;

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.

Security vulnerability: Using X-Forwarded-For without option of disabling

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.

not understanding docs

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?

pm2 module infine loop and restarting

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 !

BitBucket support

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

pm2-githook > La syntaxe du nom de fichier, de repertoire ou de volume est incorrecte

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 !

adding onError hook

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.