Comments (5)
I think there is a race condition where two daemons could be started at the same time, read the config file notice that the pid field is notbset and then write to the same repo. Also if the daemon crashes it will leave the pid field set in he config.
The daemon could create a unix socket in the $XDG_RUNTIME_DIR
dir. If the socket already exists and is bound to this means another daemon exists and the current process should exit. Else the current process can bind to the socket. Other processed could then connect to the socket to send new repos to watch or perform other commands (maybe you could have a shutdown command or a command to list all currently watched repos) The $XDG_RUNTIME_DIR
dir is removed when you log out. With this schema there is no need for any processes but the daemon to read or write the config file and any crashes will result in an unbound socket.
from dura.
@bjorn3 I like this approach. It's clean. Why not use TCP sockets? that way it would work on Windows too.
Does it require any elevated permissions to listen to a socket on localhost? On any OS that you're aware of
from dura.
A TCP socket only works when there is a single user on the local machine. It requires picking a port that isn't used by any other service. It may get blocked by a firewall (On windows you get a popup the first time it runs AFAIK. I'm not sure if you need admin permission to allow it.) And it may show up in port scans done by websites yoy visit like for example ebay is known to do.
TCP sockets may be a fine alternative when unix domain sockets are unavailable, but I think unix domain sockets are better for things like this. OS portability is not a big deal. Even windows 10 now supports them (not sure if libstd already exposes them on windows. if not you can use winapi)
from dura.
@bjorn3 Another example where this is important is tests. Right now I have a thread::sleep
to wait for the server starts. However, in the tests example I can read lines from stdout
until I get a certain message (haven't done that yet). It works there because it's a child process. We could probably do the same thing via sockets.
Regarding sockets — my bias is toward going full-fledged HTTP, because you always seem to want more out of stuff like this. Like:
GET /status
— health checks, basic statsDELETE /status
— kill current pollerGET /last_commit
— get the log entry for the last jobGET /next_commit?wait=10
— wait up to 10 seconds for the next commit
I suppose compatibility with other tools (e.g. cURL
) isn't terribly important since we can easily control the client side also. Is there a good RPC crate for unix sockets?
from dura.
If you use http please make sure to check that the Origin
header doesn't point to a website to prevent a security hole.
from dura.
Related Issues (20)
- Update: Upgrade clap to V3.1.6 & replace deprecated code in main.rs HOT 2
- Dura doesn't create any branches on github codespaces HOT 2
- brew install dura HOT 4
- Couldnt you just git commit more often? HOT 4
- Error: UnbornBranch HOT 6
- Update clap
- Data Corruption: Don't allow dura to run as root
- Ubuntu install instructions HOT 2
- Don’t create unnecessary branches
- Chronological git log HOT 2
- feature request: remove old dura branches periodically HOT 1
- support install linux and macOS with brew HOT 15
- `dura checkout` command HOT 6
- Tests broken HOT 3
- Binaries built by Github are not working HOT 6
- Prevent pushin dura branches to remote HOT 4
- stabilize config loading HOT 2
- Dura fails to capture anything if a worktree is present as a subdir of the working directory HOT 4
- Make dura branch names more informative HOT 3
- Feature Request: `dura status` command HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dura.