Fix gearman setup

This commit is contained in:
Shivam Mathur 2021-04-19 01:05:21 +05:30
parent 12d6e834b7
commit 70cd53866f
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
5 changed files with 2821 additions and 2815 deletions

View File

@ -58,18 +58,7 @@ describe('Extension tests', () => {
); );
linux = await extensions.addExtension('gearman', '7.0', 'linux'); linux = await extensions.addExtension('gearman', '7.0', 'linux');
expect(linux).toContain('gearman.sh 7.0'); expect(linux).toContain('gearman.sh');
linux = await extensions.addExtension('gearman', '7.1', 'linux');
expect(linux).toContain('gearman.sh 7.1');
linux = await extensions.addExtension('gearman', '7.2', 'linux');
expect(linux).toContain('gearman.sh 7.2');
linux = await extensions.addExtension('gearman', '7.3', 'linux');
expect(linux).toContain('gearman.sh 7.3');
linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('gearman.sh 7.4');
linux = await extensions.addExtension('xdebug2', '7.2', 'linux'); linux = await extensions.addExtension('xdebug2', '7.2', 'linux');
expect(linux).toContain('add_pecl_extension xdebug 2.9.8 zend_extension'); expect(linux).toContain('add_pecl_extension xdebug 2.9.8 zend_extension');

1177
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -153,13 +153,9 @@ export async function addExtensionLinux(
return; return;
// match 5.6gearman..7.4gearman // match 5.6gearman..7.4gearman
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
command = script +=
'\nbash ' + '\n. ' + path.join(__dirname, '../src/scripts/ext/gearman.sh');
path.join(__dirname, '../src/scripts/ext/gearman.sh') + return;
' ' +
version +
pipe;
break;
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script += script +=

View File

@ -1,9 +1,22 @@
release_version=$(lsb_release -s -r) # Helper function to add gearman extension.
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/pkg-gearman -y add_gearman_helper() {
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y add_ppa ondrej/pkg-gearman
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y libgearman-dev
enable_extension gearman extension
if ! check_extension gearman; then
status="Installed and enabled"
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"${version:?}"-gearman || pecl_install gearman
enable_extension gearman extension
fi
}
if [ "$release_version" = "18.04" ]; then # Function to add gearman extension.
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y libgearman-dev php"$1"-gearman add_gearman() {
elif [ "$release_version" = "16.04" ]; then status="Enabled"
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1"-gearman add_gearman_helper >/dev/null 2>&1
fi if check_extension gearman; then
add_log "${tick:?}" "gearman" "$status"
fi
}
add_gearman

View File

@ -82,6 +82,16 @@ pecl_install() {
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1 yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
} }
# Function to enable existing extensions.
enable_extension() {
if [ -e /tmp/setup_php_dismod ] && grep -q "$1" /tmp/setup_php_dismod; then
sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
fi
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
echo "$2=$ext_dir/$1.so" | sudo tee -a "$pecl_file" >/dev/null
fi
}
# Function to test if extension is loaded # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 extension=$1
@ -106,6 +116,7 @@ remove_extension() {
extension=$1 extension=$1
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
sudo phpdismod -v "$version" "$extension" sudo phpdismod -v "$version" "$extension"
echo "$extension" | sudo tee -a /tmp/setup_php_dismod >/dev/null 2>&1
fi fi
delete_extension "$extension" delete_extension "$extension"
} }