-
Notifications
You must be signed in to change notification settings - Fork 35
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
Support running as a daemon / service #19
Comments
Hi! Thanks for the kind words. Running as a daemon definitely makes sense, but just isn't something I've gotten to needing/building. Daemonizing the Which would be great, but again just haven't gotten around to it. I don't have a ton of free/hacking time lately, so personally won't get a chance to work on it. If you want to hack around with something like: https://commons.apache.org/proper/commons-daemon/ Or maybe: https://github.com/brianm/gressil I can provide feedback on PRs/etc. |
Thanks for the reply. |
Hey @shinebayar-g ! At our organisation we've basically followed the same path as you've described (Unison) and hit the same downsides (lack of real-time sync). As well as same conclusions regarding lsyncd :D We simply packed mirror into a custom docker image and we're running this on each server. We've organised it in start topology (1 server and many clients). So far works like a charm, but it's not handling any severe production loads yet. We sync whole /var/www path with it, that stores deployed code (with Unison we've synced particular paths in that root) |
@shinebayar-g You can use the following commands:
|
Funnily enough, I just finished writing a init.d script before looking here to put forward my own feature request, so I may as well post my (admittedly somewhat amateurish) attempt to daemonise: Assuming mirror is installed in the path,
|
@fezzzza nice, thanks! |
Well, that at least works to give me an autostart on the server although someone more experienced with Linux than me pointed out that I'm actually running through systemd, though I guess it's backwards compatible with this init script. The client script I have devised so far does not work on autostart because it's trying to resolve DNS before the internet connectivity is fully up, but it seems to work at least manually. Here it is: mirror-client can go in /usr/local/bin or your preferred location alongside the mirror executables which need to be in your $PATH:
mirror-client.conf either belongs in ~/.mirror or /etc/mirror if you are running it as root to daemonise:
Don't forget to make them both executable as before. I'm abandoning any hope of getting this to autorun right now because my use case is a roaming laptop that will be ducking in and out of internet connectivity, and the 2 big unanswered questions for me are:
Probably the wrong place to put a feature request, but seeing as I'm sharing my progress, just to keep things in one place: I need to connect one workstation to multiple servers, dependent on which set of code I'm modifying, and don't believe that's possible at the moment. A simple fix would be to be able to have multiple instances of mirror running and specify the port number in the options (both client and server side) and thereby communicate with each server via multiple ssh tunnels, each with its own port number. As I'm handling connection state manually for the time being, I'll just start and stop whichever connection suits by modifying the above to select between specified .conf files. I've just edited the code above to show the variant for those who are interested. Anyone using this please be aware I'm under no delusion that this is "good" code, so use with caution! Then the icing on the cake would be to implement rsync to minimise network traffic, but I know you've already put that down as a non-goal... just my 2p ;) Thanks, Stephen, for your work so far - it's made my job as an amateurish webdev much easier. |
FWIW http://www.harding.motd.ca/autossh/ might be "good enough" to keep auto-detect/reconnect the tunnels for you.
The tunneling aside, mirror should notice the disconnect, and repeatedly ping for when the reconnect is back, then reconnect and resync. It should generally just work. The only caveat is that if both sides have drifted way out of sync, mirror does a ~dumb "last-write-wins" union/merge. Admittedly, I should really get around to implementing this; personally I boot up my server and laptop and then: 1) manually run |
Thanks. I have updated my scripts above that you may freely incorporate into your package (you can see the edit history for older versions) and will further update it for autossh if and when I get a chance. Same warning goes though - I'm not really a bash programmer by any stretch of the imagination, so take nothing for granted that this is "good" code! However I've hit a bunch of problems that I've filed issues for, some of which are making it impossible for me to continue with mirror for the time being. Would love to come back to it if you get time to deal with these issues as it's wonderfully lightweight. Best of luck! |
@fezzzza thanks for the scrips, any update on these as well ? /edit Please update your copy/paste code as it's missing some quotes :) |
Hi, first of all this project looks awesome. But I don't know if it's fitting for my use case, I couldn't figure it out all myself. So here goes my question
I have a directory that needed to be synced on 2 servers. I was considering to use lsyncd , but readme page says this project is better at doing master-master / two way sync.
I couldn't figure out how to run this software as background daemon or at startup. Actually couldn't even run it successfully.
Currently I've setup unison software. It's simple yet awesome. But downside is it's not realtime or automated. I made crontab entry for every minute to run the script to manually sync it.
If you don't mind could you please guide me through the process?
The text was updated successfully, but these errors were encountered: