Giter VIP home page Giter VIP logo

Comments (1)

daveaglick avatar daveaglick commented on June 5, 2024 1

How to terminate Statiq with a not-0 exit error code when something has failed on start?

It should already be doing this. It'll try to continue processing files within certain modules that run concurrently if it can, that way you don't have to play whack-a-mole by fixing one file, running, fixing the next error, running, fixing the next error, running, etc. If you can see all the errors from a given module like Razor at once, it's a lot faster to fix things. But then at the end, if any errors/exceptions were logged, it'll exit with a non-zero exit code. I've got lots of CI code that runs Statiq and relies on this behavior, is it not doing that for you?

I've enabled Strict mode for the bootstrapper

It actually looks like "strict mode" is a holdover from Wyam code and isn't used in Statiq at all. In general, Statiq should be behaving as if it were in "strict mode" all the time. There is a FailureLogLevel setting you can set which is probably what Strict used to do, but provides more control. Try setting this:

Bootstrapper.Factory.CreateWeb(args)
   .AddSetting(Keys.FailureLogLevel, LogLevel.Warning)

Is it possible to add custom metadata to a document in run-time (in the pipeline code, etc)?

Absolutely - if writing a custom module, there are a series of extensions that can do this. A document is immutable, so you create a new document, passing any additional metadata you want, and the original is cloned with that new metadata. The CreateDocument() extensions exist for both the IExecutionContext and IDocument to make them easy to find.

There's a bunch of ways to write your own module code, from creating a whole module to doing something like this using the ExecuteConfig module:

await Bootstrapper.Factory
    .CreateWeb(args)
    .BuildPipeline(
        "MyPipeline",
        builder => builder.WithProcessModules(
            new ReadFiles("*.foo"),
            new ExecuteConfig(
                Config.FromDocument((ctx, doc) =>
                    doc.CreateDocument(new MetadataItems
                    {
                        { "Foo", "Bar" }
                    })))))

You don't even need to go that far though if you just want to add some metadata during the pipeline - the SetMetadata module has your back:

await Bootstrapper.Factory
    .CreateWeb(args)
    .BuildPipeline(
        "MyPipeline",
        builder => builder.WithProcessModules(
            new ReadFiles("*.foo"),
            new SetMetadata("Foo", Config.FromDocument(doc => "Bar")))

from statiq.web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.