-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suitable for syncing? #1
Comments
Hi, I frequently need to run scripts on remote servers and it's a pain because first I have to look up what servers the application actually deploys to, and then I have to get all of their info like IP, login, pass, deployment path, etc... I got so tired of doing this I added a feature to phingistrano called "remote". It's in the deploy submodule but you dont actually have to do a full deployment to use it. What I do is I call from the command line:
That will bring up an interactive prompt where you can enter a command, and when you enter it, it will be performed on all of your production servers defined in your properties. So for instance if you had a database script called syncdb.sh I would put the script on the deployment server (assuming its on a uniform path in every server)
The code behind the scenes is very simple, you dont even need the whole phingistrano repository to do something like this --- (but you need the libssh dependency unfortunately... thats a dependency that the phing ssh target requires)
That code is just an example for demonstration purposes but it should be pretty close. The deploy.remote target is part of phingistrano but if you're not doing deployments then I'd recommend just using the simple snippet I posted. I don't have code for explicitly syncing databases yet but from what it sounds like you already have the utility to do that and just need a way to automate it. Let me know if I can help any further. |
oh I forgot to mention the reason I pipe the password in the command is that if your deployment user has sudo privelages on debian you can put your command with sudo -S like this
If you want to do something like this be sure to check out the SSH phing extension and make sure you have the dependencies it can be tricky to use: Install ssh2 library on Fedora 13+ &RHEL 6+ yum install libssh2-devel Install the PHP Bindings for libssh2 Once you've installed the SSH2 library, install the PHP extension with PECL sudo pecl install channel://pecl.php.net/ssh2-0.11.2 |
Interesting. Thanks for all the info...I'll have to read up on this. Basically, I'm only trying to go one way at a time, and yeah, I'm not really doing a deployment per se. I'm running scripts that I want to do stuff like run local commands (rsync and something called drush and stuff) that will go to a central server, and it'd be great if I could pass some arguments to them based on my Phingistrano configuration...so that I can change stuff in one place, you know? Then as part of the same or a different command (so being able to combine them is helpful) I'd want to run a command on a particular remote server (probably never several at a time, but maybe) that pulls stuff from that central server via the same sorts of commands or scripts. So to sum it up...right now the main thing I'd like is to have a central place for my configuration. I could just as easily do up a conf file, I guess, but it's like...there's a tool that already does this...plus more that maybe I'll want later...and I want to avoid rolling my own stuff as much as possible, even though a lot of the actual tasks that run will be custom to me. To put some context to it, I'm trying to get something in place so I can sync up my development environments pretty fast. Usually I have my stuff on a server that I remote into, but if traveling I might want to put everything on a VirtualBox image in short order for when I don't have Internet...etc. |
So if you're running the Phingistrano and want to add some customized commands/configurations I've found the best way to do it is to import a custom phing configuration file for that project. In my example I call it "helpers". I just did something nearly exactly what you're talking about for a symfony project I've worked on. Basically I keep the helpers file around to add customizations because I dont want to put project level customizations in the build repository. So the phing confiig loads an external file with the import target like this:
In the build helpers I had a lot of remote commands that were needed for the project but I didnt want to type in the commands all the time because they were all the same set of symfony2 commands so it was convenient to set up additional targets for each command.
Looks kinda messy but its just a set of customized commands used in the same way as my first example, except they're static commands nested in custom targets. The best part about doing this is the ability to aggregate your custom targets. Like for instance, every time I deploy, i migrate the database, warm the assets and clear the cache. So in order to make that very simple I can aggregate all those targets with depends like so:
Ive found target aggregation to be a very powerful thing with phing because it allows you to use the commands on an individual basis but you can also chain them into routines. |
Ooh...I have to get more familiar with the Phing XML, but this does look Greatly appreciate you taking the time to explain that! And interesting On Tue, Jun 21, 2011 at 3:33 PM, jessegreathouse <
|
yea you could do all of the above. np glad to help out. GL. |
So I started setting this up today (as you have no doubt guessed). You were saying I don't even necessarily need the submodule to do what I want; is that to say that Phing itself would probably suffice? Is Phingistrano basically just an additional set of re-usable Phing targets? Trying to get it all together in my head as to what plays what role. It's interesting stuff :) |
That's correct. Phing is it's own application that provides a way to Phingistrano is a utility that I and my colleagues created with phing to The thing that makes Phingistrano helpful is that once you've written a On 6/23/2011 9:04 PM, wizonesolutions wrote:
|
Hey there,
So I guess my use case is essentially deployment, but I wanted to bounce it off someone just to get my thoughts in order.
I'm doing up some scripts to sync some databases and files...and it'd be nice to be able to issue different commands depending on which of them I actually want to run. Much like Capistrano.
I probably don't need any of the deployment magic (i.e. creation of release directories and whatnot), but I can turn that off anyway right? Maybe it's overkill and I should just use shell scripts that run other shell scripts. I tend to overkill things.
Thoughts appreciated!
The text was updated successfully, but these errors were encountered: