在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:yyx990803/pod开源软件地址:https://github.com/yyx990803/pod开源编程语言:JavaScript 88.6%开源软件介绍:POD - git push deploy for Node.jsCore 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. 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 TasteOn 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
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 .
├── repos # holds the bare .git repos
│ └── example.git
└── apps # holds the working copies
└── example
├──app.js
└──.podhook CLI Usage
Web Service$ pod web [stop|restart|status] This command will start the pod web service, by default at port 19999, which provides several functionalities:
Both Using a remote GitHub repoYou can setup an app to track a remote GitHub repo by using the $ pod remote my-remote-app username/repo After this, add a webhook to your GitHub repo pointing at your web interface's 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. ConfigurationThe config file lives at 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 DirectlyPod relies on pm2 for process management under the hood. When installing pod, the Logging is delegated to If things go wrong and restarting is not fixing them, try 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 HookBy default pod will run Example 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 Using the APINOTE: the API can only be used after you've initiated the config file via command line.
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 imagesReady to go docker images: Changelog0.9.1
0.9.0
0.8.6
0.8.0
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论