Git Product home page Git Product logo

pod's Introduction

POD - git push deploy for Node.js

screenshot

NPM version Build Status

Core API JSCoverage: 95.52%

Pod simplifies the workflow of setting up, updating and managing multiple Node.js apps on a Linux server. Perfect for hosting personal Node stuff on a VPS. There are essentially two parts: 1. git push deploy (by using git hooks) and 2. process management (by using pm2)

It doesn't manage DNS routing for you (personally I'm doing that in Nginx) but you can use pod to run a node-http-proxy server on port 80 that routes incoming requests to other apps.

A Quick Taste

On the server:

$ pod create myapp

On your local machine:

$ git clone ssh://your-server/pod_dir/repos/myapp.git
# hack hack hack, commit
# make sure your main file is app.js
# or specify "main" in package.json
$ git push

You can also just add it as a remote to an existing local repo:

$ git remote add deploy ssh://your-server/pod_dir/myapp.git
$ git push deploy master

That's it! App should be automatically running after the push. For later pushes, app process will be restarted. There's more to it though, read on to find out more.

Prerequisites

  • Node >= 0.10.x
  • git
  • properly set up ssh so you can push to a repo on the VPS via ssh

Installation

$ [sudo] npm install -g pod

To make pod auto start all managed apps on system startup, you might also want to write a simple upstart script that contains something like this:

# /etc/init/pod.conf
start on (local-filesystems and net-device-up IFACE!=lo)
exec sudo -u <username> /path/to/node /path/to/pod startall

The first time you run pod it will ask you where you want to put your stuff. The structure of the given directory will look like this:

.
├── repos # holds the bare .git repos
│   └── example.git
└── apps # holds the working copies
    └── example
        ├──app.js
        └──.podhook

CLI Usage


  Usage: pod [command]

  Commands:

    create <app>            Create a new app
    remote <app> <repo>     Create a app from a remote GitHub repo
    rm <app>                Delete an app
    start <app>             Start an app monitored by pm2
    stop <app>              Stop an app
    restart <app>           Restart an app that's already running
    list                    List apps and status
    startall                Start all apps not already running
    stopall                 Stop all apps
    restartall              Restart all running apps
    prune                   Clean up dead files
    hooks                   Update hooks after a pod upgrade
    web [command]           Start/stop/restart the web interface
    help                    You are reading it right now

Web Service

$ pod web [stop|restart|status]

This command will start the pod web service, by default at port 19999, which provides several functionalities:

  • / : a web interface that displays current apps status.
  • /json : returns app status data in json format.
  • /jsonp : accepts jsonp. This route must be enabled in config.
  • /hooks/appname : trigger fetch/restart for corresponding remote apps.

Both / and /json require a basic http authentication. Make sure to set the username and password in the config file.

Using a remote GitHub repo

Walkthrough

You can setup an app to track a remote GitHub repo by using the pod remote command:

$ pod remote my-remote-app username/repo

After this, add a webhook to your GitHub repo pointing at your web interface's /hooks/my-remote-app. The webhook will trigger a fetch and restart just like local apps. By default a remote app will be tracking the master branch only, if you want to track a different branch, you can change it in the config file.

You can also set up a remote app to track an arbitrary git address. However in that case you need to manually make a POST request conforming to the GitHub webhook payload.

Starting in 0.8.2, GitLab webhooks are also supported.

Starting in 0.8.6, Bitbucket webhooks are also supported.

Configuration

The config file lives at ~/.podrc. Note since 0.7.0 all fields follow the underscore format so check your config file if things break after upgrading.

Example Config:

{
    // where pod puts all the stuff
    "root": "/srv",

    // default env
    "node_env": "development",

    // this can be overwritten in each app's package.json's "main" field
    // or in the app's configuration below using the "script" field
    "default_script": "app.js",

    // minimum uptime to be considered stable,
    // in milliseconds. If not set, all restarts
    // are considered unstable.
    "min_uptime": 3600000,

    // max times of unstable restarts allowed
    // before the app is auto stopped.
    "max_restarts": 10

    // config for the web interface
    "web": {
        // set these! default is admin/admin
        "username": "admin",
        "password": "admin",
        "port": 19999,
        // allow jsonp for web interface, defaults to false
        "jsonp": true
    },

    "apps": {
        "example1": {

            // passed to the app as process.env.NODE_ENV
            // if not set, will inherit from global settings
            "node_env": "production",

            // passed to the app as process.env.PORT
            // if not set, pod will try to parse from app's
            // main file (for displaying only), but not
            // guarunteed to be correct.
            "port": 8080,

            // pod will look for this script before checking
            // in package.json of the app.
            "script": "dist/server.js",

            // *** any valid pm2 config here gets passed to pm2. ***

            // spin up 2 instances using cluster module
            "instances": 2,

            // pass in additional command line args to the app
            "args": "['--toto=heya coco', '-d', '1']",

            // file paths for stdout, stderr logs and pid.
            // will be in ~/.pm2/ if not specified
            "error_file": "/absolute/path/to/stderr.log",
            "out_file": "/absolute/path/to/stdout.log"
        },
        "example2": {
            // you can override global settings
            "min_uptime": 1000,
            "max_restarts": 200
        },
        "my-remote-app": {
            "remote": "yyx990803/my-remote-app", // github shorthand
            "branch": "test" // if not specified, defaults to master
        }
    },

    // pass environment variables to all apps
    "env": {
        "SERVER_NAME": "Commodore",
        "CERT_DIR": "/path/to/certs"
    }
}

Using PM2 Directly

Pod relies on pm2 for process management under the hood. When installing pod, the pm2 executable will also be linked globally. You can invoke pm2 commands for more detailed process information.

Logging is delegated to pm2. If you didn't set an app's out_file and error_file options, logs will default to be saved at ~/.pm2/logs.

If things go wrong and restarting is not fixing them, try pm2 kill. It terminates all pm2-managed processes and resets potential env variable problems.

All pod commands only concerns apps present in pod's config file, so it's fine if you use pm2 separately to run additional processes.

Custom Post-receive Hook

By default pod will run npm install for you everytime you push to the repo. To override this behavior and run custom shell script before restarting the app, just include a .podhook file in your app. If .podhook exits with code other than 0, the app will not be restarted and will hard reset to the commit before the push.

Example .podhook:

component install
npm install
grunt build
grunt test
passed=$?
if [[ $passed != 0 ]]; then
    # test failed, exit. app's working tree on the server will be reset.
    exit $passed
fi
# restart is automatic so no need to include that here

You can also directly edit the post-receive script of an app found in pod-root-dir/repos/my-app.git/hooks/post-receive if you wish.

Using the API

NOTE: the API can only be used after you've initiated the config file via command line.

require('pod') will return the API. You have to wait till it's ready to do anything with it:

var pod = require('pod')
pod.once('ready', function () {
    // ... do stuff
})

The API methods follow a conventional error-first callback style. Refer to the source for more details.

Docker images

Ready to go docker images:

Changelog

0.9.1

  • Move to latest pm2
  • Added support for Node 7.x

0.9.0

  • Support env option in .podrc which passes environment variables to all apps managed by pod.
  • Fixed GitHub ping event error when using remote GitHub repo.

0.8.6

  • Added support for Bitbucket webhooks.
  • Added ability to specify entry point in app's config in .podrc by using the script field.
  • Fixed issue with the readline module blocking stdin. This caused issues when attempting to clone a repository that required a username/password.

0.8.0

  • Upgrade pm2 to 0.12.9, which should make pod now work properly with Node 0.11/0.12 and latest stable iojs.
  • Fix web services to accommodate github webhook format change (#29)
  • Now links the pm2 executable automatically when installed

0.7.4

  • Fix web service strip() function so it processes github ssh urls correctly. (Thanks to @mathisonian)
  • Behavior regarding main field in package.json is now more npm compliant. (e.g. it now allows omitting file extensions)

0.7.3

  • Add a bit more information for first time use
  • Renamed the web service process name to pod-web-service from pod-web-interface.
  • Fixed web service not refreshing config on each request

0.7.2

  • Add styling for the web interface.

0.7.1

  • Now pod automatically converts outdated config files to 0.7.0 compatible format.

0.7.0

  • Config file now conforms to underscore-style naming: nodeEnv is now node_env, and defaultScript is now default_script. Consult the configuration section for more details.
  • Added pod web and pod remote commands. See web interface and using a remote github repo for more details.
  • Removed pod config and pod edit.
  • Drop support for Node v0.8.

0.6.0

  • The post receive hook now uses git fetch --all + git reset --hard origin/master instead of a pull. This allows users to do forced pushes that isn't necesarrily ahead of the working copy.
  • Added pod prune and pod hooks commands. Make sure to run pod hooks after upgrading pod, as you will want to update the hooks that are already created in your existing apps.
  • Upgraded to pm2 0.6.7

License

MIT

pod's People

Contributors

bnns avatar coderofsalvation avatar cpius avatar jonathanmh avatar leeroybrun avatar mathisonian avatar meldsza avatar michaelowens avatar mjhasbach avatar orthographic-pedant avatar psirenny avatar taylorzane avatar yyx990803 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

pod's Issues

app's working directory is user home

When I start the pod of a node project which writes and reads files, it is trying to do it relative to my home path instead of from the app. Is there a setting I can put in the .podrc that sets my current working directory?

pod start, stop and restart hang

Hi there,

when using pod start, stop and restart it hangs and never exits, doesn't print anything to the console either. Starting does seem to work sometimes though when Ctrl+c'ing and hitting pod list. I tried to set the env var DEBUG=api to get at least some messages what's happening, but that didn't really work. Is there any way to get more verbosity so I can see where things go wrong? For now I assume it has to do with Satan since pod list works just fine.

npm i installed 0.12.16 of pm2, is that version known to work?

Pod Remote Private Repo over HTTPS Causes Freeze

When trying to add a private repo like so:

pod remote test https://github.com/<autho>/<repo>.git

Git asks for a password, but the terminal is frozen (does not respond to Ctrl + C).

I was able to get around this by adding credentials to ~/.netrc, but that is not ideal.

pod returns 500 error on first github ping

This was really confusing for me at first, I followed the instructions exactly for adding a GitHub hook but then I got the red error symbol.

screen shot 2016-04-27 at 23 09 37

The problem is that before GitHub sends any push events, it sends a "ping" event to test if the connection is working. It could be great to have pod respond to that with a 200 OK status instead of throwing the error TypeError: Cannot read property "length" of undefined, to avoid confusion.

I added a note about this to the wiki for now https://github.com/yyx990803/pod/wiki/Using-a-remote-repo#3-setup-github-remote-hook

pod remote stuck

Hi

I am trying to create app with github tracking with command pod remote app stfoo/app but it outputs message Username for 'https://github.com': and blocks terminal, so I can't input any symbols or even interrupt pod with ctrl+c.

After it in pod list I see this:

root@stfoo:~# pod list

    name      status      port      restarts      uptime      memory      CPU 

    book      BROKEN      ????                                                

allow bare filenames in package.json

npm allows package.json to have fields like

  "main": "./server",

but pod throws an error

POD ERR cannot locate main script for <appname> (poddir/apps/appname/./server)

unless this is converted to "main": "./server.js"

Add support for "forever" in configuration

I would very much like to use forever to ensure my server remains running even if it crashes. I dont think it would be that hard to change up the config and cli.sh to accommodate for that.

pod rm hangs

pod rm appname hangs after a really delete appName? (y/N) prompt I press y and press enter than nothing happens ... same for pod prune

Upgrade to pm2 0.14.x

There are several really nice improvements in the new pm2 0.14.x such as the --lines parameter among others. I'm not sure if the breaking changes between 0.12.x and 0.14.x is a problem or if pod could just upgrade without any modifications?

Support for handling java apps

This may be way out of scope but could you add support for running java apps?

I have an architecture where my node server interacts with a java server via a socket io connection. My node server is set up already with pod and i have tried several things using the .podhook file in order to get my java server running but it does not appear to be working.

In the java server repo i have a jar file that starts the server which i run via (in the .podhook file):

screen -A -m -d -S java-server sh path/to/repo/start_java_server.sh

when i attempt to reattach to the screen after committing and pushing to the repo there are no screens which leads me to believe that the .podfile is not running due to the fact that i dont have an app.js file in the java server repo. I havent tried adding a app.js file yet, i suppose i could try that but would prefer not to have a useless node service running for the sake for spinning up a java server.

Perhaps we could modify the configuration to allow for repositories with no app.js file?

pod web POD ERR method "findByFullPath" does not exist

On a fresh Ubuntu 16.04 Digital Ocean VPS, after installing Node 6.x

~$ npm install -g pod
~$ pod
Hello! It seems it's your first time running pod on this machine.
Please specify a directory for pod to put stuff in.
- Make sure your account has full access to that directory.
- You can use relative paths (resolved against your cwd).
path: pod
target path /root/pod doesn't exist. create it? (y/N)y
...
~$ pod web
POD ERR method "findByFullPath" does not exist

Any chance for .podrc within each project?

Instead of ~/.podrc make it look within the project's dir for .podrc and then ~/.podrc? Would help with the deployment process/not having to edit one gigantic file if I have 40 projects (I like to modularize a lot of things).

Port number do not come to pm2 satan

PM2 require port number for visualization, but in your code (api.js):

for (var o in appInfo.config) {
if (
o !== 'port' &&
o !== 'node_env' &&
o !== 'remote' &&
o !== 'username' &&
o !== 'password' &&
o !== 'jsonp'
) {
app[o] = appInfo.config[o]
}
}

Maybe you'll remove o !== 'port' ? It will solve the issue.

pod hangs just after initialisation

Hello,

First, I want to thank you for this very usefull utility. I've already used it with success on other projects and this just works perfectly as expected !

Today I've just installed a brand new VM with Ubuntu Server 12.04 and wanted to install POD to easily manage my apps.

Node.js and POD installed without any issues, but when I want to create my first app (and init the pod folders), it just hangs after creating the config file.

myuser@my-app:~$ pod create my-app
Hello! It seems it's your first time running pod on this machine.
Please specify a directory for pod to put stuff in.
- Make sure your account has full access to that directory.
- You can use relative paths (resolved against your cwd).
path: ./pod-apps
target path /home/myuser/pod-apps doesn't exist. create it? (y/N)          y

POD created root directory: /home/myuser/pod-apps
POD created repos directory: /home/myuser/pod-apps/repos
POD created apps directory: /home/myuser/pod-apps/apps
POD created config file at: /home/myuser/.podrc

I've tried to cancel the process and launch pod list or any other commands, but it hangs immediatly and nothing happens.

Here is the .podrc created automatically :

{
    "root": "/home/myuser/pod-apps",
    "node_env": "development",
    "default_script": "app.js",
    "apps": {},
    "web": {}
}

Do you have any idea where it can come from ?

Thanks for your help.

Can't get it working.

I did a normal install, the pod command works but the install has issues

npm http GET https://registry.npmjs.org/pod
npm http 304 https://registry.npmjs.org/pod
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/cli-table
npm http GET https://registry.npmjs.org/ejs
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/pm2
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/colors
npm http 304 https://registry.npmjs.org/cli-table
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/ejs
npm http 304 https://registry.npmjs.org/pm2
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/colors/0.3.0
npm http GET https://registry.npmjs.org/connect/2.12.0
npm http GET https://registry.npmjs.org/commander/1.3.2
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET https://registry.npmjs.org/fresh/0.2.0
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/methods/0.1.0
npm http GET https://registry.npmjs.org/send/0.1.4
npm http GET https://registry.npmjs.org/cookie-signature/1.0.1
npm http GET https://registry.npmjs.org/merge-descriptors/0.0.1
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/commander/2.1.0
npm http GET https://registry.npmjs.org/pm2-multimeter/0.1.2
npm http GET https://registry.npmjs.org/usage/0.3.9
npm http GET https://registry.npmjs.org/axon-rpc/0.0.2
npm http GET https://registry.npmjs.org/watch/0.8.0
npm http GET https://registry.npmjs.org/axon/1.0.0
npm http GET https://registry.npmjs.org/cron/1.0.1
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/eventemitter2/0.4.13
npm http GET https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/range-parser/0.0.4
npm http 304 https://registry.npmjs.org/connect/2.12.0
npm http 304 https://registry.npmjs.org/cookie/0.1.0
npm http 304 https://registry.npmjs.org/colors/0.3.0
npm http 304 https://registry.npmjs.org/commander/1.3.2
npm http 304 https://registry.npmjs.org/fresh/0.2.0
npm http 304 https://registry.npmjs.org/buffer-crc32/0.2.1
npm http 304 https://registry.npmjs.org/send/0.1.4
npm http 304 https://registry.npmjs.org/methods/0.1.0
npm http 304 https://registry.npmjs.org/cookie-signature/1.0.1
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/merge-descriptors/0.0.1
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/keypress
npm http 304 https://registry.npmjs.org/axon-rpc/0.0.2
npm http 304 https://registry.npmjs.org/watch/0.8.0
npm http 304 https://registry.npmjs.org/commander/2.1.0
npm http GET https://registry.npmjs.org/batch/0.5.0
npm http GET https://registry.npmjs.org/qs/0.6.6
npm http GET https://registry.npmjs.org/bytes/0.2.1
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http GET https://registry.npmjs.org/uid2/0.0.3
npm http GET https://registry.npmjs.org/raw-body/1.1.2
npm http GET https://registry.npmjs.org/negotiator/0.3.0
npm http GET https://registry.npmjs.org/multiparty/2.2.0
npm http 304 https://registry.npmjs.org/pm2-multimeter/0.1.2
npm http 304 https://registry.npmjs.org/usage/0.3.9
npm http 304 https://registry.npmjs.org/axon/1.0.0
npm http 304 https://registry.npmjs.org/cron/1.0.1
npm http 304 https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/eventemitter2/0.4.13
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/commander/1.0.5
npm http GET https://registry.npmjs.org/ms/0.6.2
npm http GET https://registry.npmjs.org/charm
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/configurable/0.0.1
npm http GET https://registry.npmjs.org/escape-regexp/0.0.1
npm http 304 https://registry.npmjs.org/pause/0.0.1
npm http 304 https://registry.npmjs.org/qs/0.6.6
npm http 304 https://registry.npmjs.org/uid2/0.0.3
npm http 304 https://registry.npmjs.org/bytes/0.2.1
npm http 304 https://registry.npmjs.org/batch/0.5.0
npm http 304 https://registry.npmjs.org/raw-body/1.1.2
npm http 304 https://registry.npmjs.org/negotiator/0.3.0
npm http 304 https://registry.npmjs.org/multiparty/2.2.0
npm http 304 https://registry.npmjs.org/commander/1.0.5
npm http 304 https://registry.npmjs.org/ms/0.6.2
npm http 304 https://registry.npmjs.org/charm
npm http 304 https://registry.npmjs.org/bindings

> [email protected] install /usr/lib/node_modules/pod/node_modules/pm2/node_modules/usage
> node-gyp rebuild

npm http 304 https://registry.npmjs.org/configurable/0.0.1
npm http 304 https://registry.npmjs.org/escape-regexp/0.0.1
make: Entering directory `/usr/lib/node_modules/pod/node_modules/pm2/node_modules/usage/build'
  CXX(target) Release/obj.target/sysinfo/src/binding.o
  SOLINK_MODULE(target) Release/obj.target/sysinfo.node
  SOLINK_MODULE(target) Release/obj.target/sysinfo.node: Finished
  COPY Release/sysinfo.node
make: Leaving directory `/usr/lib/node_modules/pod/node_modules/pm2/node_modules/usage/build'
npm http GET https://registry.npmjs.org/readable-stream
npm http GET https://registry.npmjs.org/stream-counter
npm http 304 https://registry.npmjs.org/readable-stream
npm http 304 https://registry.npmjs.org/stream-counter
npm http GET https://registry.npmjs.org/core-util-is
npm http GET https://registry.npmjs.org/isarray/0.0.1
npm http GET https://registry.npmjs.org/string_decoder
npm http GET https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/isarray/0.0.1
npm http 304 https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/core-util-is
/usr/bin/pod -> /usr/lib/node_modules/pod/bin/pod
npm WARN unmet dependency /usr/lib/node_modules/block-stream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-ignore requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/fstream-npm requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/glob requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/npmconf requires inherits@'~2.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/tar requires inherits@'2' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
[email protected] /usr/lib/node_modules/pod
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

api.getAppInfo do not support pm2 style script definition

Look at ./podrc notation

{
apps: {
appname: {
... pm2 application configuration + some extras
}
}

currently in code:

info.script = path.resolve(info.workPath, getAppMainScript(info.workPath) || globalConfig.default_script)

maybe this is more clean?
info.script = path.resolve(info.workPath, getAppMainScript(info.workPath) || info.config.script || globalConfig.default_script)

  • add o !== 'script' && in prepareConfig() for sure

cause .script is pm2 script path.

not working on node 0.12.0

gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 2.6.32-504.8.1.el6.x86_64
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Linux 2.6.32-504.8.1.el6.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "pod"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the usage package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls usage
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /opt/mybooking/npm-debug.log

`pod` command conflict with CocoaPods

Just letting you know another opensource command line tool is already using pod, CocoaPods.

In the interest of devs like myself using Objective-C and JavaScript, changing the name would avoid confusion and install issues.

pod web times out on long builds

Github times out because pod web is not responding to its POST quickly enough. For example, if I'm doing a gulp build that takes longer than 30 seconds.

Maybe res.end() should happen outside of executeHook() ?

i.e.

if (app && verify(req, app, payload)) {
        executeHook(appid, app, payload)
        res.end()
    }

instead of

if (app && verify(req, app, payload)) {
        executeHook(appid, app, payload, function () {
            res.end()
        })
    }

port not exposed

configuration: alpine linux docker

.podrc

{
    "root": "/srv",
    "node_env": "development",
    "default_script": "app.js",
    "apps": {
        "microservice": {
            "port": 4000,
            "PORT": 4000,
            "script": "/srv/apps/microservice/index.js"
        }
    },
    "web": {
        "username": "admin",
        "password": "test",
        "port": 19999,
        "jsonp": true
    }
}

index.js

....
console.log("listening to http requests @ port "+process.env.PORT)                                                                                                                                
console.dir(process.env)
http.createServer(router).listen(process.env.PORT) 

output

{ HOSTNAME: 'nodepod',
  SHELL: '/bin/bash',
  TERM: 'xterm',
  MICROSERVICES: '1',
  CONFIGPROXY_AUTH_TOKEN: 'test',
  PROXY: '1',
  USER: 'nodejs',
  PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  _: '/usr/bin/pod',
  PWD: '/srv/apps/microservice',
  VERSION: 'v4.1.1',
  SHLVL: '2',
  LOGNAME: 'nodejs',
  HOME: '/home/nodejs',
  SILENT: 'true',
  name: 'microservice',
  env: '[object Object]',
  pm_exec_path: '/srv/apps/microservice/index.js',
  pm_cwd: '/srv/apps/microservice',
  exec_interpreter: 'node',
  instances: '1',
  exec_mode: 'cluster_mode',
  node_args: '',
  pm_out_log_path: '/home/nodejs/.pm2/logs/microservice-out-4.log',
  pm_err_log_path: '/home/nodejs/.pm2/logs/microservice-error-4.log',
  pm_pid_path: '/home/nodejs/.pm2/pids/microservice-4.pid',
  NODE_APP_INSTANCE: '0',
  NODE_ENV: 'development',
  OLDPWD: '/',
  status: 'launching',
  pm_uptime: '1462300425415',
  axm_actions: '',
  axm_monitor: '[object Object]',
  axm_options: '[object Object]',
  axm_dynamic: '[object Object]',
  vizion_running: 'false',
  created_at: '1462300425278',
  pm_id: '4',
  restart_time: '6',
  unstable_restarts: '0',
  started_inside: 'false',
  command: '[object Object]',
  _pm2_version: '0.12.16',
  versioning: 'null',
  exit_code: 'SIGTERM' }
listening to http requests @ port undefined

Getting pod to play nice with authbind

I'm having major difficulties trying to start authbind, which starts node, which starts pod, which starts all NodeJS apps.

Ideally, I'd just like to inject "authbind node app.js" in to pod.

The reason for this is that I'm using port numbers under 1024, meaning that root privileges are required, but authbind allows me to circumvent this (on a port by port basis) and run as a regular user, but authbind needs to be running first.

My upstart script is currently starting it like this:
exec start-stop-daemon --start --chuid MY_USER --exec /usr/bin/authbind /usr/local/bin/node /usr/local/lib/node_modules/pod/bin/pod -- startall

What happens at the moment is that pod is properly starting my NodeJS app, but it is node playing nicely with authbind, so I'm getting this:
error: Could not start server on port MY_PORT.
error: Ports under 1000 require root privileges.
error: bind EACCES

I can verify that authbind does work as intended by just running "authbind node app.js".

Any help on this?

Support yarn

add support to yarn if the project has yarn.lock file

pod remote + pod web

pod web provides a status checking / monitor interface on the web.
This process should also expose an api endpoint to accept web hooks from Github.

Create an app with remote repository with Github shorthand:

pod remote my-remote-app username/repo

Upon receiving web hook post requests from github, this will run the same routine to fetch and restart the app.

Git branches in separate folders

i would like to send my project to separate folders on ec2 linux machine and run them as a simultaneous processes, its production and development. How can i do that?

Best,
Vladimir Minkin

Pod log file generation

Pod has been generating a new log file each time an application is restarted.

Can this be disabled anywhere? I'd ideally just want one file.

branch selection doesn't seem to work

I've got a branch specified in my .podrc but the app directory only shows the master branch. A quick search of api.js doesn't show that it's using the branch config anyway. Does this feature work?

pod start <app> freezes

Hi,
I love that this exists, however, everytime I try to create an app, it ignores the default_script setting in the APP section of the config as if it isn't being overridden. I am developing a node.js app and usually to run it, I open a screen and restart it by typing node app.js. However, because I am using visual studio to develop this app, there is always a subfolder inside the git repo. So I modify my config like this to ensure that the subdirectory is taken into account:

{
"root": "/home/git/POD",
"node_env": "development",
"default_script": "app.js",
"max_restarts": 5,
"apps": {
    "STARS": {
            "default_script":"NodejsConsoleApp3/app.js"
    }
},
"web": {}

}

However, it is completely ignoring the override in the STARS app config and still looking for /home/git/POD/apps/STARS/app.js when it should be looking for /home/git/POD/apps/STARS/NodejsConsoleApp3/app.js.

Now here is the frustrating part, if I change the global "default_script" to what I want and set it to "NodejsConsoleApp3/app.js" and then type "pod start STARS", putty appears to freeze the ssh. I have to hit CTRL+C twice to make it break it. After that, typing in "pod list", I see that my app is there, but the STATUS shows ERROR, with an instant high restart count. What is going on, all I want to do is develop nodejs in visual studio, publish to my virtual private server via git, and automatically restart my nodejs remotely on a push. Why does it freeze? It shouldn't. Even if there are no http or https objects, it still freezes. Any ideas?

add `pod prune`

pod prune shoud remove extraneous files that do not belong to any app in .podrc

Github Webhook - "SyntaxError: Unexpected token u"

Heya,

Just followed this to setup a remote repo with pod.

after running pod remote app-name organisation/app-name

I see it successfully pulled the master branch inside the /apps folder(repos folder is empty.). Next up got the web tool started and setup the webhook accordingly.

Wanted to add "bower install" along with npm install when a new fetch is done, so created the .podhook file accordingly and added it to <pod folder>/apps/<app-name>/

tweaked ~/.podrc such as:

{
    "root": "/usr/maidsafe/pod",
    "node_env": "development",
    "default_script": "server.js",
    "apps": {
        "network_visualiser": {
            "remote": "maidsafe/Network-Visualiser",
            "branch": "client-ui",
            "node_env": "production",
            "port": 8080
        }
    },
    "web": {}
}

Now when I commited to the client-ui branch, I can see the webhook executed from github interface, however the response is:

Headers
Connection: keep-alive
Date: Wed, 18 Jun 2014 13:50:38 GMT
Transfer-Encoding: chunked
X-Powered-By: Express

Body
SyntaxError: Unexpected token u

and ofc it doesn't seem to have done anything.

If i run pod hooks, I see:

POD ERR ENOENT, open '/usr/maidsafe/pod/repos/network_visualiser.git/hooks/post-receive'

As i mentioned the repos folder is empty as I'm just using a remote app setup. Also checked the logs from ~/.pm2/logs

Only thing in the err.log is:

connect.multipart() will be removed in connect 3.0

Not sure what I'm doing wrong, or if the webhook just isnt working.

This is from the web monitor/json output:

[
  {
    "name": "network_visualiser",
    "port": 8080,
    "broken": false,
    "status": "OFF",
    "uptime": null,
    "memory": null,
    "cpu": null,
    "instanceCount": 0,
    "raw": {
      "name": "network_visualiser",
      "repoPath": "/usr/maidsafe/pod/repos/network_visualiser.git",
      "workPath": "/usr/maidsafe/pod/apps/network_visualiser",
      "config": {
        "remote": "maidsafe/Network-Visualiser",
        "branch": "client-ui",
        "node_env": "production",
        "port": 8080
      },
      "script": "/usr/maidsafe/pod/apps/network_visualiser/server.js",
      "port": 8080,
      "instances": null,
      "broken": false,
      "uptime": null
    }
  }
]

POD ERR ENOENT

sudo pod create test
POD ERR ENOENT, mkdir '/home/webapp/repos/test.git'

.podrc配置如下:
{
"root": "/home/webapp",
"nodeEnv": "development",
"defaultScript": "app.js",
"editor": "vi",
"apps": {
}
}

How to track a remote gitlab repo

Starting in 0.8.2, GitLab webhooks are also supported.

But following the guide using a remote repo, it seems github is the only option for creating remote repo. So if I use pod remote foo-app at15/foo it will track github.com/at15/foo.git How can I let pod track repos in self host gitlab instance, like git.abc.com/at15/foo.git? Thanks a lot.

Pod web keeps restarting when started as non-root

It shouldn't need root for the default port, but for some reason the restarts just skyrocketing. The problem is that I create my pod apps as my own user, so running the web interface as root will work but not show any pod-apps...

Restarts

Does pod create a log file anywhere that I could check for errors?

PM2 dependency is out of date

We noticed that the pod version of PM2 is at ~0.7.7 but the latest PM2 release is now at ~0.9.4

Two fold question:

  1. Would you forsee any issue with us just installing the latest PM2 inside of pod's context in our environments?
  2. Is there any plan to officially update this dependency in a new version of pod?

Thanks very much.

初始化失败!

$ pod help
Hello! It seems it's your first time running pod on this machine.
Please specify a root directory for pod to store your apps' repos and work trees:
/home/webapp

/usr/lib/node_modules/pod/lib/cli.js:132
return cmd.split(' ')[0]
^
TypeError: Cannot call method 'split' of undefined
at stripArgs (/usr/lib/node_modules/pod/lib/cli.js:132:16)
at initConfig (/usr/lib/node_modules/pod/lib/cli.js:124:17)
at globalConfig.root (/usr/lib/node_modules/pod/lib/cli.js:98:17)
at ReadStream. (/usr/lib/node_modules/pod/lib/cli.js:159:9)
at ReadStream.g (events.js:175:14)
at ReadStream.EventEmitter.emit (events.js:95:17)
at ReadStream. (stream_readable.js:746:14)
at ReadStream.EventEmitter.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
$ sh: turning off NDELAY mode

Can't globally install pod anymore?

I've done this many times, but ever since the update to v.0.12.0, I think it broke. This is what I get when I try to do "npm install -g pod":

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.12.0" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp" child_process: customFds option is deprecated, use stdio instead. make: Entering directory `/usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/build' CXX(target) Release/obj.target/sysinfo/src/binding.o ../src/binding.cpp: In function ‘void RegisterModule(v8::Handle)’: ../src/binding.cpp:8:17: error: ‘NewSymbol’ is not a member of ‘v8::String’ target->Set(String::NewSymbol("HERTZ"), Number::New(sysconf(_SC_CLK_TCK))); ^ ../src/binding.cpp:8:77: error: no matching function for call to ‘v8::Number::New(long int)’ target->Set(String::NewSymbol("HERTZ"), Number::New(sysconf(_SC_CLK_TCK))); ^ ../src/binding.cpp:8:77: note: candidate is: In file included from /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp/0.12.0/src/node.h:61:0, from ../src/binding.h:1, from ../src/binding.cpp:1: /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local v8::Number::New(v8::Isolate*, double) static Local New(Isolate* isolate, double value); ^ /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: candidate expects 2 arguments, 1 provided ../src/binding.cpp:9:17: error: ‘NewSymbol’ is not a member of ‘v8::String’ target->Set(String::NewSymbol("PAGE_SIZE"), Number::New(sysconf(_SC_PAGESIZE))); ^ ../src/binding.cpp:9:82: error: no matching function for call to ‘v8::Number::New(long int)’ target->Set(String::NewSymbol("PAGE_SIZE"), Number::New(sysconf(_SC_PAGESIZE))); ^ ../src/binding.cpp:9:82: note: candidate is: In file included from /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp/0.12.0/src/node.h:61:0, from ../src/binding.h:1, from ../src/binding.cpp:1: /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: static v8::Local v8::Number::New(v8::Isolate*, double) static Local New(Isolate* isolate, double value); ^ /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/.node-gyp/0.12.0/deps/v8/include/v8.h:1999:24: note: candidate expects 2 arguments, 1 provided ../src/binding.cpp:17:17: error: ‘NewSymbol’ is not a member of ‘v8::String’ target->Set(String::NewSymbol("OS"), String::New(OS)); ^ ../src/binding.cpp:17:42: error: ‘New’ is not a member of ‘v8::String’ target->Set(String::NewSymbol("OS"), String::New(OS)); ^ make: *** [Release/obj.target/sysinfo/src/binding.o] Error 1 make: Leaving directory`/usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.emit (events.js:110:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12) gyp ERR! System Linux 3.13.0-43-generic gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/lib/node_modules/pod/node_modules/pm2/node_modules/usage gyp ERR! node -v v0.12.0 gyp ERR! node-gyp -v v1.0.2 gyp ERR! not ok npm ERR! Linux 3.13.0-43-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "pod" npm ERR! node v0.12.0 npm ERR! npm v2.5.1 npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the usage package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls usage
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log

Private repositories?

Hi,

Pod is successfully creating a remote app from a public github repository, but fails with "fatal: repository does not exist" for a private one. I assumed that this would work given that you can clone private repos via ssh. Am I missing something?

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.