0

I'm currently working an a rather large web project which is written using C servlets ( utilizing GWAN Web server ). In the past I've used a couple of IDEs for my LAMP/PHP jobs, like Eclipse.

My problems with Eclipse are that you can either mirror the project locally, which isn't possible in this case as I'm working on a Mac (server does not run on OSX), or use the "remote" view, which would re-upload files when you save them.

In the later case, the file is only partly written while uploading, which makes this a no-go for a running web server, or the file could become corrupted if the connection was lost during uploading. Also, for changing some character, uploading the whole file seems rather inefficient to me.


So I was thinking:

Wouldn't it be possible to have the IDE open Vim per SSH and mirror my changes there, and then just :w (save) ? Or use some kind of diff-files for changes?

The first one would be preffered, as it has the added advantage of Vim .swp files, which makes it possible that others know when someone is already editing the file.


My current solution is using ssh+vim, but then I lose all the cool features I have with Eclipse and other more advanced IDEs.

Also, regarding X-Forwarding: The reason I don't like it is speed. It feels way slower than just editing locally, and takes up unneeded bandwidth, when all I want to do is basically "text editing".

P.S.: I couldn't find any more appropriate tags for the question, especially no "remote" tag, but if you know any, feel free to add them. Also, if there is another similar question, feel free to point it out - I couldn't find any.

Thank you very much.

7
  • Anything in vim.wikia.com/wiki/Editing_remote_files_via_scp_in_vim matches your need? Commented Sep 27, 2013 at 18:35
  • @FredrikPihl no sorry, that's using vim again, and scp as well, which means uploading the whole file again. Both things I want to avoid. But thanks for the link. Commented Sep 27, 2013 at 18:37
  • Have a local copy of the sources, edit locally (probably using Eclipse), build locally until all looks good, upload the modified files, build on the remote host, test on the remote host, patch on the remote host, download the patched files and start over. Commented Sep 27, 2013 at 18:41
  • I can't "build locally" ( "mirror the project locally, which isn't possible in this case as I'm working on a Mac (server does not run on OSX)" ), and also, this again has the problem of partial files while uploading. Of course, I could upload to a different directory and move them on the server then, but for web developement, where you normally edit just a bit (a line, correct a typo etc) and then press reload in the browser, this is/would be a huge hassle - the reason why I'm currently using Vim directly on the server (and the reason for this question) Commented Sep 27, 2013 at 18:46
  • Ok, I understood you were referring to C coded "servlets". Btw, just out of curiosity: You are editing on a live-system? shudder Commented Sep 27, 2013 at 19:01

2 Answers 2

2

If you're concerned about having to transmit the entire file for minor changes, the only solution that comes to my mind is running (either continuously, or on demand) an rsync job that mirrors the remote site to your local system (and back). The rsync protocol just transmits the delta information. According to Are rsync operations atomic at file level?, the change is atomic.

Sign up to request clarification or add additional context in comments.

7 Comments

Actually a very interesting idea! Do you know of a way to use this with an IDE (Eclipse would be cool) and make it run on demand? I think it could be done with ANT scripting or the like, but unfortunately I don't know enough about Eclipse + ANT to build a nice integration there, so I would not have to edit the script every time for a new server/different path ... Also, a more local-caching like approach would be nice, so I don't flood my disk with source files over time, but that's more of an added bonus if it is possible I guess ;)
@griffin: rsync was exactly what I had in mind when I commented: "... upload ... download ..." on the OP.
@alk sorry, I can't read your mind :/ And I know rsync, just didn't think about using it in this way / for this problem. My question/comment still stands though, as this is "only" a first piece of the puzzle I guess ;)
With Vim, you could trigger on the BufWritePost event, but I would probably just run this continuously in a loop, from a little shell script that configures the paths to sync.
That would mean having a script for each server / path I work on right? Also, a loop would probably have to run every second or so, as that's about the time it takes me to cmd+tab & cmd+r to switch to browser and reload :/ (btw upvoted your answer for now, trying to think of a complete rsync based solution right now, but I'm still far off unfortunately :( )
|
1

Another possibility: run everything in a virtual machine on your Mac. The server and the IDE/text editor are both on the same virtual machine so you don't have to fear network issues.

Because the source code on the virtual machine is under some kind of VCS the classic code → test → commit process is trivial (at least theoretically).

2 Comments

A nice idea, but the question was more meant to be a general one, as I'm normally working on many other servers as well, though with a LAMP/PHP setup there. Also, a local vm is not as well suited for developing in teams / with more people. But still, upvote for thinking "outside of the box" (at least for this question your answer is) ;)
More like "thinking inside the virtual box" ;-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.