Add shards count configuration

This commit is contained in:
Wieland Schöbl
2021-05-28 20:26:40 +02:00
parent 0c123a6567
commit fa00466eb0
3 changed files with 47 additions and 33 deletions

39
.idea/workspace.xml generated
View File

@@ -4,12 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="">
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Update stuff">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Admin.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Admin.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DataIO.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/DataIO.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Main.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Main.kt" afterDir="false" />
</list>
<list id="44283a45-f406-407f-bce2-a31bb9bfc0cc" name="Changes by Valentin" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -71,9 +71,13 @@
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/build/libs" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="codeWithMe.voiceChat.enabledByDefault" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
@@ -93,6 +97,17 @@
</key>
</component>
<component name="RunManager" selected="Kotlin.Main">
<configuration default="true" type="ArquillianJUnit" factoryName="" nameIsGenerated="true">
<option name="arquillianRunConfiguration">
<value>
<option name="containerStateName" value="" />
</value>
</option>
<option name="TEST_OBJECT" value="class" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="HytaleUpdateBot [build]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
<ExternalSystemSettings>
<option name="executionName" />
@@ -188,6 +203,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1597322033373</updated>
<workItem from="1622225780094" duration="598000" />
</task>
<task id="LOCAL-00001" summary="Add auto publish feature">
<created>1597437833375</created>
@@ -231,9 +247,19 @@
<option name="project" value="LOCAL" />
<updated>1622221667210</updated>
</task>
<option name="localTasksCounter" value="7" />
<task id="LOCAL-00007" summary="Update stuff">
<created>1622224992757</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1622224992757</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
@@ -253,7 +279,8 @@
<MESSAGE value="fix crash on missing permission&#10;add removeInactive command" />
<MESSAGE value="prepare twitter integration" />
<MESSAGE value="Update Json Serialization" />
<option name="LAST_COMMIT_MESSAGE" value="Update Json Serialization" />
<MESSAGE value="Update stuff" />
<option name="LAST_COMMIT_MESSAGE" value="Update stuff" />
</component>
<component name="XDebuggerManager">
<watches-manager>

View File

@@ -31,6 +31,7 @@ data class AdminFile(
val adminId: Long = 12345,
val token: String = "12345",
val updateMs: Long = 30000,
val shards: Int = 6,
val watchingMessage: String = "for new Blogposts",
val offlineMessage: String = "CONNECTION FAILED",
var twitterApi: TwitterApi? = TwitterApi()

View File

@@ -27,30 +27,26 @@ object Main {
fun main(args: Array<String>) {
val builder = JDABuilder.createLight(
Admin.token,
GatewayIntent.GUILD_MESSAGES, GatewayIntent.DIRECT_MESSAGES
)
.setActivity(Activity.watching(Admin.message))
GatewayIntent.GUILD_MESSAGES,
GatewayIntent.DIRECT_MESSAGES
).setActivity(Activity.watching(Admin.message))
configureMemoryUsage(builder)
for (i in 0 until 6) {
for (i in 0 until Admin.adFile.shards) {
try {
var jda = builder.useSharding(i, 6)
.build()
jda.addEventListener(AdminCli())
jda.addEventListener(ErrorHandler())
jda.addEventListener(OwnerCli())
jda.awaitReady()
jdas.add(
jda
)
jdas.add(builder.useSharding(i, Admin.adFile.shards).build().apply {
addEventListener(AdminCli())
addEventListener(ErrorHandler())
addEventListener(OwnerCli())
awaitReady()
})
} catch (loginException: LoginException) {
println("!!! Shard $i could not login !!!")
}
}
Admin.connectToUser()
Admin.info()
Runtime.getRuntime().addShutdownHook(object : Thread() {
@@ -68,11 +64,9 @@ object Main {
}
}
// Grab the Scheduler instance from the Factory
val scheduler = StdSchedulerFactory.getDefaultScheduler()
// and start it off
scheduler.start();
// define the job and tie it to our TwitterJob class
scheduler.start()
val job: JobDetail = newJob(TwitterJob::class.java)
.withIdentity("job1", "group1")
.build()
@@ -84,23 +78,15 @@ object Main {
.withSchedule(cronSchedule("0 0/5 * 1/1 * ? *"))
.build()
// Tell quartz to schedule the job using our trigger
scheduler.scheduleJob(job, trigger);
}
fun configureMemoryUsage(builder: JDABuilder) {
// Disable cache for member activities (streaming/games/spotify)
private fun configureMemoryUsage(builder: JDABuilder) {
builder.disableCache(CacheFlag.ACTIVITY)
// Only cache members who are either in a voice channel or owner of the guild
builder.setMemberCachePolicy(MemberCachePolicy.VOICE.or(MemberCachePolicy.OWNER))
// Disable member chunking on startup
builder.setChunkingFilter(ChunkingFilter.NONE)
// Disable presence updates and typing events
builder.disableIntents(GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_MESSAGE_TYPING)
// Consider guilds with more than 50 members as "large".