summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2023-11-21Document docker-compose.ymlHEADv0.2.0masterMalfurious1-0/+6
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-21Update READMEMalfurious1-36/+130
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-20acid: Base job reason strictly on source updatesMalfurious1-2/+1
I find the previous logic to be a little unhelpful. Every job executing in a batch was classified based on whether we were in the middle of maintenance or not. Therefore even a service with actual new updates would get serviced via a "maint" build job. Now, reasons are determined on a per-job basis. We consider a job event-triggered if there are new sources (acid-source returns 1). This allows for a mix of reason types in a batch of jobs that more accurately reflects the state of sources while doing work. This also means that any source errors result in the job being considered "maint". Below is the effective truth table for determining job reason. acid-source result forcing builds not forcing -------------------------------------------------------- 0 (no action) maint -- 1 (new files) event event 2 (error) maint maint Signed-off-by: Malfurious <m@lfurio.us>
2023-11-20dmt: Add stats pageMalfurious3-0/+23
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-20dmt: jobs: Invert default refresh timeMalfurious1-2/+2
Whenever we encounter an exception (which is usually due to a network problem), default to the active refresh time as to recover from the situation as soon as possible. Eg: Only wait the full idle time when the server successfully reports it is idle. There isn't even a real concern here of request load on the server, since we can't reach the server in this condition anyway. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-20dmt: Add faviconMalfurious3-0/+6
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-18dmt: Add services pageMalfurious4-1/+60
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-18dmt: Escape unintended HTML entitiesMalfurious2-4/+8
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-18dmt: css: Rename remove class to standoutMalfurious2-3/+3
The css class originally used to represent service removal jobs is renamed to "standout". I wish to reuse it in other exceptional contexts which should draw the user's attention - which of course also covers the case of service removal. "Standout" is a more generic term for this. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-18dmt: jobs: Scope javascript to this pageMalfurious2-1/+2
The script.js file is only really intended to run against the main jobs page at this point. So, move its inclusion from the page master to the jobs page specifically. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-17README ~~.txt~~Malfurious1-0/+0
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-17acid: source: Only record commit hashesMalfurious1-6/+7
Previously, the object hash computed by `git for-each-ref` was the value we cached in the 'previous_hash' file. If the matching ref was an annotated tag, then this was the tag's hash, not the commit hash it pointed to. Now, always dereference tags to their commit object, and store this value instead. This consistency will improve the web UX in my opinion. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-17acid: source: Initialize cached hash to NULLMalfurious1-1/+1
For some consistency, initialize repos' previous_hash to the NULL hash (all zeros). This should prevent empty values on the user interface. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-17acid: source: Prevent creation of local branches/refsMalfurious1-4/+15
Previously (and as is the default behavior in git), when cloning fresh cache repositories for user services, we would acquire current remote-tracking branches, tags, and a local branch tracking origin/HEAD. In practice, this local branch becomes vestigial. As we fetch updates, we always checkout by commit hash and leave the repository in a detached HEAD. The local branch reference is therefore never updated. This is fine for the functionality of ACID. However, if querying the repo for information about the current version, it is possible for tools like `git describe` to describe HEAD in terms of this stale branch ref. Now, when we clone a repository arrange for there to be no 'local' branch references. Only remote-tracking branches and tags. Remote-tracking branches are properly updated and removed by our fetch command. Additionally, prevent the remote 'origin/HEAD' symbolic ref, since it would be mildly confusing for it to pop up to the user as well. In effect, we limit our ref namespace only to branches and tags that actually exist on the remote host. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Implement initial functionality for jobs pageMalfurious4-4/+171
Adds javascript to implement self-hydration for the main page. Several aspects of these features can be customized via new settings in config.sh. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Add routing / proper request handlingMalfurious1-2/+30
All requests are handled by interpreting the $PATH_INFO environment variable, which is set by the main path component of the HTTP request. All requests are assumed to be GET requests, as no other request method is supported. Elements in the $PATH_INFO are split into an array on the '/' delimiter, and we apply some sanity checks to the string to prevent potential exploits. Routes are established for all present API endpoints and valid resources / pages. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Add main page layoutMalfurious4-1/+58
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Add stylesheetMalfurious1-0/+103
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Implement API endpoint /api/log/{jobnum}Malfurious1-1/+11
This returns a plain-text response (not JSON) of the full log file for the requested job number. If `jobnum` is omited, the log of the latest job is returned. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Implement API endpoint /api/job/{jobnum}Malfurious2-1/+35
This returns all details related to the requested job number as well as a tail of the job log file. If `jobnum` is omited, details of the latest job are returned. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Implement API endpoint /api/statusMalfurious2-0/+37
This returns high-level information describing the current state of the system. The intent of the `version` field is primarily to act as a "page should be reloaded" indicator to the front-end javascript code. This would inform the client to reload (possibly) new markup or script whenever the version field changes. This field could return an accurate version spec of cychedelic or DMT, however just returns a random string at the moment which is tied to the DMT docker image build. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Add server-side templating functionalityMalfurious1-0/+55
This file is taken from the "werc" web "anti-framework" project, which is made available as Public Domain as well as MIT code. It is an awk script that implements a simple templating markup syntax. When run on an input file, it translates the content into equivalent shell syntax which can then be executed to produce the desired result. Therefore, the script should be invoked as `template.awk FILE | bash`, and the output can be streamed to the client. An overview of the template syntax follows: Lines beginning with '%' (no leading whitespace allowed) are taken as shell commands. Inline %{ ... %} gives the inner content taken as a shell command. Inline %( ... %) gives the inner content taken as a shell expression (which is substituted). All other text is echoed as-is. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-15dmt: Add service containerMalfurious2-0/+35
DMT (Display for Monitoring log Text) will be the HTTP monitoring interface for cychedelic. We mount the system data as readonly for this purpose. The Dockerfile is largely based on that of ACID for the moment, as I anticipate the same underlying packages. Also, the web service entry is written to be intended for use with the nginx-proxy reverse proxy. CGD is an extremely simple daemon used for serving a CGI script over HTTP. It is available as Public Domain / MIT code. DMT's entrypoint will be implemented as a CGI shell script. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-02acid: Produce job logs for service removalMalfurious1-2/+9
Signed-off-by: Malfurious <m@lfurio.us>
2023-11-02acid: Rework build log recordsMalfurious1-35/+31
Two new pieces of metadata are now included in a job record: the git commit hash, and an indicator of the job execution reason (aka: push event, or periodic maintenance). The job records themselves are converted into directories containing files which define these metadata. Previously, all metadata was packed (underscore-delimited) into the log filename. The indication of job PASS/FAIL is no longer given by a line of text appended to the log. Instead, a file named 'fail' will exist in the directories of failed jobs. The semantics of the status file are further defined by this patch as well. The file will contain: "": when the system is idle "maint": when maintenance is in progress (inbetween jobs) a job number: when a job is in progress and the file will _always_ exist. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-02acid: source: Return null hash on errorMalfurious2-6/+12
This seems like a more consistent behavior. Also, I would like to embed the git hash into the build log record somehow. Returning all zeroes in an error case allows the main script to simply pass along the result instead of worrying about an edge case. Signed-off-by: Malfurious <m@lfurio.us>
2023-11-02Merge data volumesMalfurious5-19/+27
I need something more complicated than just 1 new directory for logs, so let's go to the trouble now of merging the persistent volumes together and use subdirectories/files. The default location is now '/data'. To aid similar changes in the future, the locations of these persistent files are no longer hard-coded in the source, but defined by global shell variables. Additionally, a bug is fixed which impacted our ability to accurately clean old logs and calculate the next job number. Signed-off-by: Malfurious <m@lfurio.us>
2023-10-26acid: Prune old build logs during startup maintenanceMalfurious2-0/+4
Signed-off-by: Malfurious <m@lfurio.us>
2023-10-26acid: Manage persistent build logsMalfurious1-6/+43
The output from build jobs are now stored in dedicated log files instead of being dumped to stdout. Files are saved in the new volume at /logs and intended to be accessed by the web interface for auditing there. Files are named like "X_Y_Z.log" where X = a unique build number, Y = a timestamp in UNIX epoch seconds, and Z = the corresponding service name. Log files are simply closed when the job is finished, so the UI can check for the existence of a file "/logs/active" which indicates that the highest-numbered job is still in progress. This file is removed afterward. Failed jobs have a "JOB FAILED" message appended at the end of their log. Successful jobs simply lack this message. One reason this is the case is due to the build for cychedelic (--self) losing execution before success can be affirmatively determined. Signed-off-by: Malfurious <m@lfurio.us>
2023-10-26Add new volume for long-term build log outputMalfurious1-0/+3
Signed-off-by: Malfurious <m@lfurio.us>
2023-10-26acid: Don't use 'cychedelic' in file namesMalfurious5-8/+8
As I add new components to the cychedelic system, it would be best to use more specific naming. 'cychedelic' is the name of the project, whereas 'acid' is the name of this program. Signed-off-by: Malfurious <m@lfurio.us>
2023-09-11Add READMEv0.1Malfurious1-0/+140
Signed-off-by: Malfurious <m@lfurio.us>
2023-09-10Add UNLICENSEMalfurious1-0/+24
Signed-off-by: Malfurious <m@lfurio.us>
2023-09-10acid: Sanitize filename inputs from the configMalfurious2-0/+12
Prevent the creation or access of unintended files in the ACID container. Also, assert that names are valid for docker before attempting to deploy images. Signed-off-by: Malfurious <m@lfurio.us>
2023-09-10acid: remove: Don't rely on YML fileMalfurious1-9/+4
Per the previous two commits, the docker-compose.yml file is not needed when running `docker compose down`. Update the cyche-remove script to cope with a lack of such a file. Also per the latest commit, arrange to always call docker compose with the explicit --project-name. Signed-off-by: Malfurious <m@lfurio.us>
2023-09-10acid: build: Always specify --project-nameMalfurious1-10/+10
The script is refactored to always provide an explicit --project-name option to docker compose. Still taken from the $CYCHE_SERVICES config and only modified if --self is given. This addresses an issue when using a docker-compose.yml from within a subdirectory. If --project-name is omitted, the directory name used by docker is the one containing the YML file, not the working directory (git repository root). When calling `docker compose down` (when given --self), we now omit the --file as it is unnecessary. Signed-off-by: Malfurious <m@lfurio.us>
2023-09-10Revert "acid: build: Cache path to the docker-compose.yml file"Malfurious2-2/+0
This ends up being unnecessary. We don't need the content of the YML file to correctly clean up resources. Docker compose inherently knows how to handle it. As long as we operate with the correct --project-name (whether it's explicitly given, or determined by current directory), `docker compose down` will do the job. We can therefore run from a workind directory that is unrelated to the target service, even if it contains a different docker-compose.yml file. This reverts commit 7a7ff89ff16542d30ff7c1f70689236b8fd9c607. Signed-off-by: Malfurious <m@lfurio.us>
2023-09-08acid: Remove running services no longer present in $CYCHE_SERVICESMalfurious2-0/+32
If a service was previously managed by cychedelic, but an update to the cyche code removes it from the config file, stop the service and delete the git clone. As usual, this should leave any docker volumes intact. Signed-off-by: Malfurious <m@lfurio.us>
2023-09-08acid: build: Cache path to the docker-compose.yml fileMalfurious2-0/+2
When a service entry is removed from $CYCHE_SERVICES, this value is lost, preventing us from properly tearing down the service. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-19acid: Touch up some documentationMalfurious2-4/+4
Signed-off-by: Malfurious <m@lfurio.us>
2023-08-18acid: Add sleep between executing jobsMalfurious2-0/+4
The loop in the main update function will sleep for a configurable amount of time between each job / service entry. This added time will make the output log easier to read on-the-fly, but this change also makes the process of rapidly rebuilding services that are dependent on each other more reliable. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-18acid: source: Display git submodule entries in the logMalfurious1-1/+1
It can be useful to confirm which submodules (and versions) are present for a build, and the output isn't all that noisy either. Just 1 or 2 lines should be printed for each submodule. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-18acid: source: Summarize commit we are building fromMalfurious1-0/+3
For the sake of the logs, print out the oneline summary of the commit we deemed to be the latest available for deployment. The `git checkout "$next"` command that is run just a couple lines up would also display this information if we didn't redirect it to /dev/null. However, it also produces other noisy output such as the "You are in detached HEAD state" message or "Leaving X commits behind" warning. Therefore, just summarize the commit ourselves. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-18acid: Improve git error handlingMalfurious2-11/+16
Exit early from the cyche-source script on key git errors, where previously we would mindlessly continue on to execute a bunch of broken commands. Errors at this stage should be caught to prevent an attempt to build and deploy the code (even --force 'd builds). Signed-off-by: Malfurious <m@lfurio.us>
2023-08-18acid: Make docker compose YML file configurableMalfurious3-15/+16
Facilitate deployments using alternate docker-compose.yml files, or projects which simply use a different filename for the configuration. This setting populates the `docker compose -f` option. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-12acid: build: Bring cychedelic down under its default name as wellMalfurious1-0/+1
If cychedelic is ever started manually, using a pre-existing data volume, the system will believe the previous instance is using a specific random project name and may not properly shutdown the user-initiated instance on a rebuild. Simply attempting to stop the service using its default name will catch this, and not cause any problems in the general case. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-12acid: build: Fix bug in cychedelic project-name generationMalfurious1-2/+4
The nested single quotes in these variables were not being interpreted correctly at their usage locations (the quoted project name was being sent to the docker cli). The quotes were initially wanted for the case where there is not yet any previous_slug, as the command "docker compose --project-name down" is ill-formed. Since we know the actual slug values will not contain spaces, we can do away with the quotes. Instead, prevent $prev from containing any content in the special case described above. This is accomplished by the conditional check [ -n "$prev" ]. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-10Add docker-compose.ymlMalfurious1-0/+13
The file will function as a service definition as well as the pseudo cychedelic config file. Signed-off-by: Malfurious <m@lfurio.us>
2023-08-10acid: Add DockerfileMalfurious1-0/+13
Signed-off-by: Malfurious <m@lfurio.us>
2023-08-09acid: Add configuration templateMalfurious1-0/+31
Signed-off-by: Malfurious <m@lfurio.us>