pac is a simple deployment tool with ssh and rsync, no scm tools required. It could work with any kind of projects which need to deploy to 1 or more *nix servers.
You may need to create a ssh account (e.g. "www") on a local server (aka "deployment server"), then on the remote server(s), allow the ssh account to login via public ssh key instead of password, see Setting up SSH public/private keys for more.
Depending on your OS, realpath
is required for the current version of pac on your deployment server. e.g. (on Debian/Ubuntu):
# apt-get install realpath
# wget https://raw.github.com/xianhuazhou/pac/master/pac.sh -O /usr/bin/pac
or with curl
# curl https://raw.github.com/xianhuazhou/pac/master/pac.sh > /usr/bin/pac
# chmod +x /usr/bin/pac
$ cd /path/to/your/project
$ pac init
There is a main configuration file called "config.sh", you can open and change the basic settings. Also, there is a "hooks" directory, you can put some hook functions there. To exclude some files to deploy, you can update the file "hooks/rsync_exclude". You can check the examples direcotry for more.
In your project directory, run:
$ pac deploy setup
$ pac deploy
$ pac deploy run
$ pac run "ls" # run the command in all servers
$ pac run "ps aux" your-remote-server.name # run only in the specified server
app related commands defined in the hooks/app.sh file.
$ pac app [start|stop|restart|...]
$ pac help
The environment variable is using by pac to determine how to do the deployment, by default it will set it to the file ".pac/config.sh" based your current working directory, however, you can change this, e.g.:
$ PACFILE=/path/to/somewhere/pac/config.sh pac deploy
$ cd /path/to/your/project
$ cp .pac/config.sh .pac/staging_config.sh # edit .pac/staging_config.sh
$ PACFILE=.pac/staging_config.sh pac deploy setup
$ PACFILE=.pac/staging_config.sh pac deploy run
It works as follows:
- pac will synchronize your project files to remote servers with rsync for each release.
- Run some hooks such as compile/merging js/css files.
- Link to the latest relase.
- Reload/Restart your app and run some other hooks if needed.
- Remove old releases and done.
Do as follows:
# sudoedit /etc/sudoers
Then add something like:
www-data ALL=NOPASSWD: /etc/init.d/php-fpm,/etc/init.d/nginx
and save it.
Then the user www-data
can run commands like sudo /etc/init.d/php-fpm reload
without password.