1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

make it easier to change php configuration

This commit is contained in:
Robin Appelman 2026-02-06 23:55:06 +01:00
commit 4bb6a21d7c
6 changed files with 71 additions and 0 deletions

View file

@ -221,6 +221,12 @@ haze update
haze [match] edit <path> haze [match] edit <path>
``` ```
#### Reload the php config of an instance
```bash
haze [match] reload
```
## Federation ## Federation
Multiple instances can reach each other by using their instance name as domain Multiple instances can reach each other by using their instance name as domain

View file

@ -4,6 +4,11 @@ touch /var/log/nginx/access.log
touch /var/log/nginx/error.log touch /var/log/nginx/error.log
touch /var/log/cron/owncloud.log touch /var/log/cron/owncloud.log
echo "# Options in here overwrite the builtin php.ini" > /php.ini
chmod 0777 /php.ini
PHP_INI_DIR="$(php --ini | grep 'Scan' | cut -d ' ' -f7)"
ln -s /php.ini "$PHP_INI_DIR/zz_extra.ini"
HAZE_UID=${HAZE_UID:-www-data} HAZE_UID=${HAZE_UID:-www-data}
HAZE_GID=${HAZE_GID:-www-data} HAZE_GID=${HAZE_GID:-www-data}

View file

@ -99,6 +99,9 @@ pub enum HazeArgs {
filter: Option<String>, filter: Option<String>,
path: String, path: String,
}, },
Reload {
filter: Option<String>,
},
} }
#[derive( #[derive(
@ -379,6 +382,7 @@ impl HazeArgs {
.ok_or_else(|| Report::msg("No path provided"))? .ok_or_else(|| Report::msg("No path provided"))?
.into(), .into(),
}), }),
HazeCommand::Reload => Ok(HazeArgs::Reload { filter }),
} }
} }
} }
@ -467,6 +471,11 @@ pub enum HazeCommand {
/// Edit a file in the instance with $EDITOR on the host /// Edit a file in the instance with $EDITOR on the host
#[strum(props(Args = "[path] file to edit"))] #[strum(props(Args = "[path] file to edit"))]
Edit, Edit,
/// Reload the php configuration in the instance
#[strum(props(
Details = "note: you can overwrite <yellow>php.ini</yellow> settings with <literal>haze</literal> <arg>[filter]</arg> <literal>edit /php.ini</literal>"
))]
Reload,
} }
impl SubCommand for HazeCommand { impl SubCommand for HazeCommand {
@ -484,6 +493,7 @@ impl SubCommand for HazeCommand {
| HazeCommand::Unpin | HazeCommand::Unpin
| HazeCommand::Env | HazeCommand::Env
| HazeCommand::Edit | HazeCommand::Edit
| HazeCommand::Reload
) )
} }

View file

@ -231,4 +231,32 @@ fn subcommand_help(command: &dyn SubCommand) {
); );
} }
} }
if let Some(details) = command.get_str("Details") {
println!("{}", format_details(details));
}
}
fn format_details(details: &str) -> String {
use std::fmt::Write;
let mut result = String::with_capacity(details.len());
for (i, part) in details.split("</").enumerate() {
let part = if i > 0 {
// strip the remaining close tag from the previous part
part.split_once('>').map(|(_, part)| part).unwrap_or(part)
} else {
part
};
let (head, tail) = part.split_once('<').unwrap_or((part, ""));
result.push_str(head);
if let Some((tag, content)) = tail.split_once('>') {
match tag {
"literal" => write!(&mut result, "{}", content.blue()).unwrap(),
"arg" => write!(&mut result, "{}", content.green()).unwrap(),
"yellow" => write!(&mut result, "{}", content.bright_yellow()).unwrap(),
_ => write!(&mut result, "{content}").unwrap(),
}
}
}
result
} }

View file

@ -470,6 +470,27 @@ async fn main() -> Result<ExitCode> {
.into_diagnostic() .into_diagnostic()
.wrap_err("Failed to start $EDITOR"); .wrap_err("Failed to start $EDITOR");
} }
HazeArgs::Reload { filter } => {
let cloud = Cloud::get_by_filter(&docker, filter, &config).await?;
exec(
&docker,
&cloud.id,
"root",
vec!["pkill", "php-fpm"],
Vec::<String>::new(),
Some(stdout()),
)
.await?;
exec(
&docker,
&cloud.id,
"root",
vec!["sh", "-c", "php-fpm --fpm-config /etc/php-fpm.conf&"],
Vec::<String>::new(),
Some(stdout()),
)
.await?;
}
}; };
Ok(ExitCode::SUCCESS) Ok(ExitCode::SUCCESS)

View file

@ -161,6 +161,7 @@ pub fn default_mappings<'a>() -> impl IntoIterator<Item = Mapping<'a>> {
.dont_create(), .dont_create(),
Mapping::new(WorkDir, "xdebug", "/tmp/xdebug"), Mapping::new(WorkDir, "xdebug", "/tmp/xdebug"),
Mapping::new(WorkDir, "profiling", "/tmp/profiling"), Mapping::new(WorkDir, "profiling", "/tmp/profiling"),
Mapping::new(WorkDir, "php.ini", "/php.ini").file(),
]; ];
IntoIterator::into_iter(mappings) IntoIterator::into_iter(mappings)
} }