-
Notifications
You must be signed in to change notification settings - Fork 24
Improved Redeploy System #330
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
Conversation
# Conflicts: # src/main/java/net/javadiscord/javabot/systems/staff_commands/RedeployCommand.java
|
It might be worthy to use a variable in the redeploy script for specifying the bot directory ( Aside from that, it would be possible to build the JAR with GitHub Actions and let the bot query the GitHub API and download that. The JAR file location (from a specific class) can also be obtained via reflection. Furthermore, it is possible to update the bot purely in Java using Finally, shutting down |
Yup, updated that.
I know, I also thought about that but I think I personally prefer to compile it myself.
What would be the benefit of that? This script is easily executable if we don't have anything else running and it seems pretty simple. |
It would be platform independent, not require the script to be located at a specific path and doesn't require any external scripts at all. This would make it easier to use in other environments. |
Yeah, but it also makes it harder to operate from outside the command which is quite important in my opinion. |
| } | ||
| Bot.getMessageCache().synchronize(); | ||
| event.getJDA().shutdown(); | ||
| System.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to move this to its own listener so that it is called when shutting down JDA completed.
| Process p = new ProcessBuilder("/bin/sh", Bot.getConfig().getSystems().getRedeployScriptLocation()).start(); | ||
| p.waitFor(); | ||
| String result = new String(p.getInputStream().readAllBytes()); | ||
| if (result.contains("COMPILATION FAILED")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use the exit code of the script for checking whether it was successful or not.
For example, there could be errors other than the Gradle script failing (e.g. with git clone).
For failing with any error, set -e could be used in the script in order to abort the script as soon as any command fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, will do that soon™️
|
Closed due to inactivity |
This PR aims to improve the redeploy system a bit. This deprecates the method described in #195.
This now requires a
shto be present at/bin/sh, in addition to an updated redeploy script to support all new features.This is the redeploy script we now use to re-compile the Bot:
As you can see this now only replaces the
.jarif the compilation was successful. This is also used in the Bot to cancel the redeploy if the compilation did not succeed.The location of this script has to be set in the Systems config. E.g.
"redeployScriptLocation": "/home/myUser/JavaBot/redeploy.sh",We still use a
systemdservice to run the bot, but we don't run this script before every start anymore, instead we only use this script for the/redeploycommand. This allows us to restart the bot without waiting for it to compile again if we don't want that.