-
Notifications
You must be signed in to change notification settings - Fork 390
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
Add docker support #4
Comments
How would I add Docker support? Can't you just install it in a Docker container? |
Your app look's really cool ! (tried Chronos from Airbnb dev team but it doesn't fit my needs ). I really want to try Cronicle, but for a test purpose (and even after for production purpose), installing it from scratch is a little annoying. Add a dockerfile to your project allow potential users to have a working Cronicle instance ready in less than 5min, perfect for a test ! I can work on it and make a Pull Request if you want ! |
Thank you for the compliment, however...
Really? It's quite literally one single shell command:
Unfortunately, I don't know anything about Docker files, so I wouldn't know how to maintain it. If I am going to officially support Docker, then I think I would need to learn all about it first. It's still a mystery to me. Thank you for your interest in Cronicle tho! It's great to see that people are finding it. |
Honestly I exaggerate a little bit 😅 You'r right, it's pretty easy to install. It's just that all my stack is made of docker, and I want to keep going. I tried to create a container with Cronicle, but i had an issue (no master elected). Don't have time to push investigation further last week, but I'm on it 😃. If you'r interested to try Docker, I recommend you Kitematic and this article from Digital Ocean. Anyway, thanks for your work ! Cronicle is really really full of cool features ! (API to schedule a job and CPU usage saved my life !) 😄 |
Thanks! Yeah, Docker seems to be taking over the world. It's only a matter of time before I have to dive in and actually learn it. 😉 I'll bet the "no master elected" issue has to do with the hostname and/or IP of your Docker instance. When Cronicle is first installed, it takes a snapshot of the current server hostname and IP, and saves them into the cluster file on disk. Then when the daemon starts up, it needs to be able to "find" itself in the list, in order to be eligible for master. If the server hostname no longer matches what it was when Cronicle was installed (which is what I suspect is happening with Docker), it can't find itself, and just becomes a slave and goes to sleep. You might be able to hack around this by forcing the server to become master on startup. This is a bit messy, but... If you edit the
Add
That might get around your problem, but I have to advise caution -- it really isn't meant to run like this. Cronicle is 100% hostname based, so the hostname of the server means everything. You could never run this server in a cluster, for example, because the other servers would never agree on who is master. The I think this is one of many things that will prevent Cronicle from working in a Docker container, unless I make some core changes. Right now, the server that Cronicle is installed on needs to keep the same hostname (and IP address). I think Docker breaks this requirement. One other thing you might be able to do is delay calling the initial setup script until your Docker container is actually live and running (and has the final hostname and IP that it will live with). The initial setup script is the thing that snapshots the hostname and IP and saves it to disk. So basically, wait until you have a running Docker container before doing this step:
|
I tried to get it working with excellent tips from @jhuckaby, but there is one hurdle left to fix. The Javascript tries to connect by websocket with the wrong IP. It uses the internal docker IP, and not the exposed IP (maybe it should use the hostname in the Setup: $ cat setup_and_start_in_debug.sh
#!/bin/bash
/opt/cronicle/bin/control.sh setup
mv /opt/cronicle/conf/config.json /opt/cronicle/conf/config.json.bak
jq '.web_socket_use_hostnames = 1' /opt/cronicle/conf/config.json.bak > /opt/cronicle/conf/config.json
/opt/cronicle/bin/debug.sh --master
In the same directory as these files run: Cronicle should now be available on |
Have you tried this configuration option: https://github.com/jhuckaby/Cronicle#web_socket_use_hostnames web_socket_use_hostnamesSetting this parameter to That may do the trick, but please note that whatever hostname your Docker container has assigned itself, this needs to be resolvable in DNS, and routable from your client machine. Good luck! |
@jhuckaby Thanks for the tips, it worked :) Updated my previous comment with this change, so my previous comment should be a fully working Docker setup. |
@jhuckaby how to start running Cronicle in normal mode instead of Deamon mode as it is exiting in my container. If i run in Debug mode it will work fine and it wont exit. This is just a slave server I dont want to run setup or anyting just start. |
I don't understand the question. If running it in debug mode solves the issue, then can you just run it in debug mode? Sorry, I don't know anything about Docker, so I don't understand the exact issue here. The debug.sh script simply runs the Node.js main script with two command-line arguments:
The |
@kozmic Thanks for working out the docker details! the only thing was missing for me was setting the hostname of the container: |
Hi everyone, I'm able to run this in docker/kubernetes by setting the hostname to a static value. The master works fine, however, none of clients joined the cluster. I have two clients running on same network and they all can talk to the server on both 3012 and 3014, I'm assuming 3014 is used for discovery. I used the same secret_key for all and below two environment variables as well.
How does the client communicate with the server? Thanks, |
It could be nice to use it with Docker !
The text was updated successfully, but these errors were encountered: