Automatically running cfpm on server start

I was looking to be able to post a new topic, but I was unable to locate. The question may be somewhat relevant to this topic. I’ve noticed that when adobe@2021 is the cfengine, the updates result in the loss of previously installed packages. Is there a way to prevent the loss when the cf update occurs?

Thank you!

There’s not a great way, but what most people do is set up an onServerInstall package script in your box.json that runs

cfpm install foo,bar,baz

every time to make sure they’re all there.

@bdw429s Which/where box.json? There are many. Can it be spec’d in a .cfconfig.json file, possibly? If possible, can you provide an example? Thank you!

The box.json for whatever sever you want the behavior to apply to, lol. If you don’t have a box.json, you’d need to create it in the web root. Package scripts are documented here:

No. CFConfig deals with configuration read or written to/from the XML and properties files in Adobe and Lucee. Installing Lucee extensions or Adobe cfpm modules is outside the scope of just writing to an XML file. It’s an entire process of downloading and installing a jar that is dependent on Adobe’s proprietary logic baked into their cfpm CLI. CFConfig doesn’t even require a server to exist to write the config! You can literally point CFConfig to an empty directory and ask it to write out all the config XML files for an Adobe 2021 server and it will happily oblige. You can start the server the next day if you want. Given scenarios like that, it’s literally impossible for CFConfig to be dealing with something like cfpm which wouldn’t even exist.

Lucee has some much better conventions for dealing with this stuff-- deploy folders and environment variables. But Adobe only gives us the cfpm CLI which comes with a lot more assumptions about how it will be used.

On a related note, in the next version of CommandBox, you’ll be able to have server scripts, which do the same thing as package scripts, but can be defined in your server.json
https://ortussolutions.atlassian.net/browse/COMMANDBOX-1404

Sure…

package set scripts.onServerInstall="cfpm install mysql,orm,axis"

Just replace that list with the actual list of modules you want to install. That command will create the following box.json:

{
    "scripts":{
        "onServerInstall":"cfpm install mysql,orm,axis"
    }
}
1 Like

Thank you.

Bear with me a bit.

I tried (some of the file has been redacted):

{
“app”:{
“cfengine”:“adobe@2021”
},
“name”:“cf21.xyz.local”,
“web”:{
“host”:“xyz.local”,
“http”:{
“port”:“80”
},
“aliases”:{
},
“webroot”:""
},
“profile”:“development”,
“scripts”:{
“onServerInstall”:“cfpm install redissessionstorage,zip,image,ftp,mail,eventgateways,debugger,document,orm,caching,ajax,scheduler,pdf,sqlserver,websocket,adminapi,spreadsheet,report,exchange,chart”
}
}

The above did not work. The file is not name “box.json” however and I do not know if the file needs to be called box.json explicitly or not.

I did a server forget .

Then, server start serverconfigfile=\server-xyz.local.json.

Am I correctly understanding?

Thanks!

Try naming the file box.json

Also, I recommend formatting your JSON before you paste it into a message. It will make it easier for people to understand your code and help you.

You can format your JSON using a site like: https://jsonformatter.curiousconcept.com/
Then you can paste it in here by starting with 3 backticks ``` paste your code on a new line, and then close with three backticks ```

Escaped example:
```
[ Your Code Here]
```

It looks like you tried to add the scripts to your server.json file instead of your box.json file.