mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 09:04:12 +02:00
make it easier to change php configuration
This commit is contained in:
parent
16cb573935
commit
4bb6a21d7c
6 changed files with 71 additions and 0 deletions
|
|
@ -221,6 +221,12 @@ haze update
|
|||
haze [match] edit <path>
|
||||
```
|
||||
|
||||
#### Reload the php config of an instance
|
||||
|
||||
```bash
|
||||
haze [match] reload
|
||||
```
|
||||
|
||||
## Federation
|
||||
|
||||
Multiple instances can reach each other by using their instance name as domain
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ touch /var/log/nginx/access.log
|
|||
touch /var/log/nginx/error.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_GID=${HAZE_GID:-www-data}
|
||||
|
||||
|
|
|
|||
10
src/args.rs
10
src/args.rs
|
|
@ -99,6 +99,9 @@ pub enum HazeArgs {
|
|||
filter: Option<String>,
|
||||
path: String,
|
||||
},
|
||||
Reload {
|
||||
filter: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(
|
||||
|
|
@ -379,6 +382,7 @@ impl HazeArgs {
|
|||
.ok_or_else(|| Report::msg("No path provided"))?
|
||||
.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
|
||||
#[strum(props(Args = "[path] file to 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 {
|
||||
|
|
@ -484,6 +493,7 @@ impl SubCommand for HazeCommand {
|
|||
| HazeCommand::Unpin
|
||||
| HazeCommand::Env
|
||||
| HazeCommand::Edit
|
||||
| HazeCommand::Reload
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
28
src/help.rs
28
src/help.rs
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
21
src/main.rs
21
src/main.rs
|
|
@ -470,6 +470,27 @@ async fn main() -> Result<ExitCode> {
|
|||
.into_diagnostic()
|
||||
.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)
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ pub fn default_mappings<'a>() -> impl IntoIterator<Item = Mapping<'a>> {
|
|||
.dont_create(),
|
||||
Mapping::new(WorkDir, "xdebug", "/tmp/xdebug"),
|
||||
Mapping::new(WorkDir, "profiling", "/tmp/profiling"),
|
||||
Mapping::new(WorkDir, "php.ini", "/php.ini").file(),
|
||||
];
|
||||
IntoIterator::into_iter(mappings)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue