Skip to content

add makefile - #1263

Draft
MaatheusGois wants to merge 4 commits into
GregHib:mainfrom
MaatheusGois:makefile-only
Draft

add makefile#1263
MaatheusGois wants to merge 4 commits into
GregHib:mainfrom
MaatheusGois:makefile-only

Conversation

@MaatheusGois

@MaatheusGois MaatheusGois commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds a top-level Makefile so contributors can start/stop/status the server without remembering the gradle wrapper invocation.

Currently the documented path is ./gradlew :game:run directly, with no way to background it cleanly or check whether it's already running. This wraps the lifecycle in five recipes:

  • make start — start the server in the background, wait for port 43594 to listen, tail the log
  • make stop — gracefully shut down (SIGTERM → 15s grace → SIGKILL), clearing any leftover listener
  • make status — show pid + port state + last log lines
  • make restartstop + start
  • make logstail -f server.log
  • make clean — wipe */build and .gradle (fixes the "Storage for [.../class-attributes.tab] is already registered" failure when a previous build died mid-write)

START_TIMEOUT overrides the readiness wait (default 600s) — make start START_TIMEOUT=900.

Notable behavior

  • start uses setsid nohup ...</dev/null so the gradle worker's child JVM is in a new session and survives the parent shell exit (the previous nohup ... & form kept getting SIGHUP'd when make returned).
  • stop and the port-cleanup fallback both verify the saved pid is still a java/bash/sh process before signalling, so a recycled pid or an unrelated listener won't get killed.

Draft because

I want a maintainer sanity check on whether a Makefile belongs in the repo at all (some projects prefer a script in scripts/ or a launchd plist), and on the chosen lifecycle approach before this gets merged. Happy to restructure — e.g. drop start/stop/status and only keep clean, since ./gradlew :game:run is one line — if that's preferred. The actual gradle commands are unchanged from what the README already recommends.

- start: use 'setsid nohup ...</dev/null &' so the gradle wrapper's child
  JVM is in a new session and SIGHUP from the parent shell can't reap it.
  The previous plain 'nohup ... &' kept dying when 'make' exited.
- start: drive the readiness loop from a configurable START_TIMEOUT (default
  600s). The hard-coded 4-min cap silently failed on every cold build
  (~4 min compile + engine startup) and trained users to ignore the warning.
- stop/status: when .server.pid is missing or points to a recycled pid,
  fall back to scanning the listener on the game port instead of erroring.
  Verify the saved pid is still a java/gradle process before signalling —
  refuse to kill an unrelated process that happens to have the same number.
- clean: wipe */build and .gradle to clear poisoned Kotlin incremental
  caches ('Storage for [.../class-attributes.tab] is already registered'
  when a previous run died mid-write).
@GregHib

GregHib commented Sep 7, 2026

Copy link
Copy Markdown
Owner

I want a maintainer sanity check on whether a Makefile belongs in the repo at all

Yeah that's what I was thinking, makefile's are more C world to me it's not something I come across very often in JVM, gradle you can use of course but it's better to use it built into your IDE; though I can appreciate not everyone wants to use IntelliJ like me.

Though the start/stop commands are nice for developers I kinda of want to discourage those who don't know what they're doing from installing programs and executing arbitrary commands that they won't know the consequences of, and for easy setups point them to releases instead. Though you could argue ofc that gradle is just abstracting that away, but I am more familiar and comfortable with it at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants