Skip to content

Instantly share code, notes, and snippets.

@charmoniumQ
Created November 26, 2024 09:24
Show Gist options
  • Save charmoniumQ/702d01d6b9da68d69a9720ed6e5da5e6 to your computer and use it in GitHub Desktop.
Save charmoniumQ/702d01d6b9da68d69a9720ed6e5da5e6 to your computer and use it in GitHub Desktop.
Broken grocy install
<?php
use Grocy\Controllers\ExceptionController;
use Grocy\Helpers\UrlManager;
use Grocy\Middleware\LocaleMiddleware;
use Grocy\Middleware\CorsMiddleware;
use Psr\Container\ContainerInterface as Container;
use Slim\Factory\AppFactory;
use Slim\Views\Blade;
// Load composer dependencies
require_once __DIR__ . '/packages/autoload.php';
// Load config files
require_once getenv('GROCY_CONFIG_FILE');
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
require_once __DIR__ . '/helpers/ConfigurationValidator.php';
// Error reporting definitions
if (GROCY_MODE === 'dev')
{
error_reporting(E_ALL);
}
else
{
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
}
// Definitions for dev/demo/prerelease mode
if ((GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease') && !defined('GROCY_USER_ID'))
{
define('GROCY_USER_ID', 1);
}
// Definitions for disabled authentication mode
if (GROCY_DISABLE_AUTH === true)
{
if (!defined('GROCY_USER_ID'))
{
define('GROCY_USER_ID', 1);
}
}
// Check if any invalid entries in config.php have been made
try
{
(new ConfigurationValidator())->validateConfig();
}
catch (EInvalidConfig $ex)
{
exit('Invalid setting in config.php: ' . $ex->getMessage());
}
// Create data/viewcache folder if it doesn't exist
if (!file_exists(GROCY_DATAPATH . '/viewcache'))
{
mkdir(GROCY_DATAPATH . '/viewcache');
}
// Setup base application
AppFactory::setContainer(new DI\Container());
$app = AppFactory::create();
$container = $app->getContainer();
$container->set('view', function (Container $container)
{
return new Blade(__DIR__ . '/views', getenv('GROCY_CACHE_DIR'));
});
$container->set('UrlManager', function (Container $container)
{
return new UrlManager(GROCY_BASE_URL);
});
$container->set('ApiKeyHeaderName', function (Container $container)
{
return 'GROCY-API-KEY';
});
// Load routes from separate file
require_once __DIR__ . '/routes.php';
// Set base path if defined
if (!empty(GROCY_BASE_PATH))
{
$app->setBasePath(GROCY_BASE_PATH);
}
if (GROCY_MODE === 'production' || GROCY_MODE === 'dev')
{
$app->add(new LocaleMiddleware($container));
}
else
{
define('GROCY_LOCALE', GROCY_DEFAULT_LOCALE);
}
$authMiddlewareClass = GROCY_AUTH_CLASS;
$app->add(new $authMiddlewareClass($container, $app->getResponseFactory()));
// Add default middleware
$app->addRoutingMiddleware();
$errorMiddleware = $app->addErrorMiddleware(true, false, false);
$errorMiddleware->setDefaultErrorHandler(
new ExceptionController($app, $container)
);
$app->add(new CorsMiddleware($app->getResponseFactory()));
$app->getRouteCollector()->setCacheFile(getenv('GROCY_CACHE_DIR') . '/route_cache.php');
ob_clean(); // No response output before here
$app->run();
$ curl https://grocy.samgrayson.me/
<br />
<b>Warning</b>: require_once(/nix/store/89z2zmy2pgdxfzs74pv6ifva8vl8kgdq-grocy-4.2.0/public): Failed to open stream: No such file or directory in <b>/nix/store/89z2zmy2pgdxfzs74pv6ifva8vl8kgdq-grocy-4.2.0/app.php</b> on line <b>15</b><br />
<br />
<b>Fatal error</b>: Uncaught Error: Failed opening required '' (include_path='.:/nix/store/kb3mgvhcpbhl1gfrv3nrdxxd3wksz4wk-php-8.3.12/lib/php') in /nix/store/89z2zmy2pgdxfzs74pv6ifva8vl8kgdq-grocy-4.2.0/app.php:15
Stack trace:
#0 /nix/store/89z2zmy2pgdxfzs74pv6ifva8vl8kgdq-grocy-4.2.0/public/index.php(45): require_once()
#1 {main}
thrown in <b>/nix/store/89z2zmy2pgdxfzs74pv6ifva8vl8kgdq-grocy-4.2.0/app.php</b> on line <b>15</b><br />
Nov 26 03:22:06 remote systemd[1]: Starting PHP FastCGI Process Manager service for pool grocy...
░░ Subject: A start job for unit phpfpm-grocy.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit phpfpm-grocy.service has begun execution.
░░
░░ The job identifier is 1267.
Nov 26 03:22:06 remote php-fpm[2006]: [NOTICE] fpm is running, pid 2006
Nov 26 03:22:06 remote php-fpm[2006]: [NOTICE] ready to handle connections
Nov 26 03:22:06 remote php-fpm[2006]: [NOTICE] systemd monitor interval set to 10000ms
Nov 26 03:22:06 remote systemd[1]: Started PHP FastCGI Process Manager service for pool grocy.
░░ Subject: A start job for unit phpfpm-grocy.service has finished successfully
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit phpfpm-grocy.service has finished successfully.
░░
░░ The job identifier is 1267.
Type=notifyNov 26 03:22:06 remote systemd[1]: Starting PHP FastCGI Process Manager service for pool grocy...
░░ Subject: A start job for unit phpfpm-grocy.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit phpfpm-grocy.service has begun execution.
░░
░░ The job identifier is 1267.
Nov 26 03:22:06 remote php-fpm[2006]: [NOTICE] fpm is running, pid 2006
Nov 26 03:22:06 remote php-fpm[2006]: [NOTICE] ready to handle connections
Nov 26 03:22:06 remote php-fpm[2006]: [NOTICE] systemd monitor interval set to 10000ms
Nov 26 03:22:06 remote systemd[1]: Started PHP FastCGI Process Manager service for pool grocy.
░░ Subject: A start job for unit phpfpm-grocy.service has finished successfully
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit phpfpm-grocy.service has finished successfully.
░░
░░ The job identifier is 1267.
ExitType=main
Restart=always
RestartMode=normal
NotifyAccess=main
RestartUSec=100ms
RestartSteps=0
RestartMaxDelayUSec=infinity
RestartUSecNext=100ms
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
TimeoutAbortUSec=1min 30s
TimeoutStartFailureMode=terminate
TimeoutStopFailureMode=terminate
RuntimeMaxUSec=infinity
RuntimeRandomizedExtraUSec=0
WatchdogUSec=0
WatchdogTimestampMonotonic=0
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=2006
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
FileDescriptorStorePreserve=restart
StatusText=Ready to handle connections
StatusErrno=0
Result=success
ReloadResult=success
CleanResult=success
UID=[not set]
GID=[not set]
NRestarts=0
OOMPolicy=stop
ReloadSignal=1
ExecMainStartTimestamp=Tue 2024-11-26 03:22:06 CST
ExecMainStartTimestampMonotonic=829773039
ExecMainExitTimestampMonotonic=0
ExecMainHandoffTimestamp=Tue 2024-11-26 03:22:06 CST
ExecMainHandoffTimestampMonotonic=829827203
ExecMainPID=2006
ExecMainCode=0
ExecMainStatus=0
ExecStart={ path=/nix/store/dpdpnmjisq6349404bkl5vzpbc2da07j-php-with-extensions-8.2.24/bin/php-fpm ; argv[]=/nix/store/dpdpnmjisq6349404bkl5vzpbc2da07j-php-with-extensions-8.2.24/bin/php-fpm -y /nix/store/zgjas7fmlyh3m1r91mi8vz8i6nvb9spj-phpfpm-grocy.conf -c /nix/store/2kzix8dlxyqfv3p9fvs931rmc7y71sdz-php.ini ; ignore_errors=no ; start_time=[Tue 2024-11-26 03:22:06 CST] ; stop_time=[n/a] ; pid=2006 ; code=(null) ; status=0/0 }
ExecStartEx={ path=/nix/store/dpdpnmjisq6349404bkl5vzpbc2da07j-php-with-extensions-8.2.24/bin/php-fpm ; argv[]=/nix/store/dpdpnmjisq6349404bkl5vzpbc2da07j-php-with-extensions-8.2.24/bin/php-fpm -y /nix/store/zgjas7fmlyh3m1r91mi8vz8i6nvb9spj-phpfpm-grocy.conf -c /nix/store/2kzix8dlxyqfv3p9fvs931rmc7y71sdz-php.ini ; flags= ; start_time=[Tue 2024-11-26 03:22:06 CST] ; stop_time=[n/a] ; pid=2006 ; code=(null) ; status=0/0 }
ExecReload={ path=/nix/store/cqnb5spmpzvc32h16568s028frzvz8hs-coreutils-9.5/bin/kill ; argv[]=/nix/store/cqnb5spmpzvc32h16568s028frzvz8hs-coreutils-9.5/bin/kill -USR2 $MAINPID ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecReloadEx={ path=/nix/store/cqnb5spmpzvc32h16568s028frzvz8hs-coreutils-9.5/bin/kill ; argv[]=/nix/store/cqnb5spmpzvc32h16568s028frzvz8hs-coreutils-9.5/bin/kill -USR2 $MAINPID ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
Slice=system-phpfpm.slice
ControlGroup=/system.slice/system-phpfpm.slice/phpfpm-grocy.service
ControlGroupId=5637
MemoryCurrent=10674176
MemoryPeak=11091968
MemorySwapCurrent=0
MemorySwapPeak=0
MemoryZSwapCurrent=0
MemoryAvailable=7016210432
EffectiveMemoryMax=8092819456
EffectiveMemoryHigh=8092819456
CPUUsageNSec=68560000
TasksCurrent=3
EffectiveTasksMax=9206
IPIngressBytes=0
IPIngressPackets=0
IPEgressBytes=0
IPEgressPackets=0
IOReadBytes=0
IOReadOperations=0
IOWriteBytes=0
IOWriteOperations=0
Delegate=no
CPUAccounting=yes
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=infinity
CPUQuotaPeriodUSec=infinity
IOAccounting=yes
IOWeight=[not set]
StartupIOWeight=[not set]
BlockIOAccounting=yes
BlockIOWeight=[not set]
StartupBlockIOWeight=[not set]
MemoryAccounting=yes
DefaultMemoryLow=0
DefaultStartupMemoryLow=0
DefaultMemoryMin=0
MemoryMin=0
MemoryLow=0
StartupMemoryLow=0
MemoryHigh=infinity
StartupMemoryHigh=infinity
MemoryMax=infinity
StartupMemoryMax=infinity
MemorySwapMax=infinity
StartupMemorySwapMax=infinity
MemoryZSwapMax=infinity
StartupMemoryZSwapMax=infinity
MemoryZSwapWriteback=yes
MemoryLimit=infinity
DevicePolicy=closed
TasksAccounting=yes
TasksMax=9206
IPAccounting=yes
ManagedOOMSwap=auto
ManagedOOMMemoryPressure=auto
ManagedOOMMemoryPressureLimit=0
ManagedOOMPreference=none
MemoryPressureWatch=auto
MemoryPressureThresholdUSec=200ms
CoredumpReceive=no
Environment=LOCALE_ARCHIVE=/nix/store/jqqfl6nl1l4kj07gwn84cv1fzmwilnn5-glibc-locales-2.40-36/lib/locale/locale-archive PATH=/nix/store/cqnb5spmpzvc32h16568s028frzvz8hs-coreutils-9.5/bin:/nix/store/mx757zkaiyr6d4qcl902i6qd6wgmksk2-findutils-4.10.0/bin:/nix/store/hz0n7bgpmnkvd83kz7ahgd899yiwrvsa-gnugrep-3.11/bin:/nix/store/i3f50210jpp4wmzkpds6l7zbp81ds4xf-gnused-4.9/bin:/nix/store/pnabxmab15j0jrh19rrins6fx3ip8j38-systemd-256.6/bin:/nix/store/cqnb5spmpzvc32h16568s028frzvz8hs-coreutils-9.5/sbin:/nix/store/mx757zkaiyr6d4qcl902i6qd6wgmksk2-findutils-4.10.0/sbin:/nix/store/hz0n7bgpmnkvd83kz7ahgd899yiwrvsa-gnugrep-3.11/sbin:/nix/store/i3f50210jpp4wmzkpds6l7zbp81ds4xf-gnused-4.9/sbin:/nix/store/pnabxmab15j0jrh19rrins6fx3ip8j38-systemd-256.6/sbin TZDIR=/nix/store/bkjfb1j7v2yax4501fyws8ha13mfancm-tzdata-2024b/share/zoneinfo
UMask=0022
LimitCPU=infinity
LimitCPUSoft=infinity
LimitFSIZE=infinity
LimitFSIZESoft=infinity
LimitDATA=infinity
LimitDATASoft=infinity
LimitSTACK=infinity
LimitSTACKSoft=8388608
LimitCORE=infinity
LimitCORESoft=infinity
LimitRSS=infinity
LimitRSSSoft=infinity
LimitNOFILE=524288
LimitNOFILESoft=1024
LimitAS=infinity
LimitASSoft=infinity
LimitNPROC=30687
LimitNPROCSoft=30687
LimitMEMLOCK=8388608
LimitMEMLOCKSoft=8388608
LimitLOCKS=infinity
LimitLOCKSSoft=infinity
LimitSIGPENDING=30687
LimitSIGPENDINGSoft=30687
LimitMSGQUEUE=819200
LimitMSGQUEUESoft=819200
LimitNICE=0
LimitNICESoft=0
LimitRTPRIO=0
LimitRTPRIOSoft=0
LimitRTTIME=infinity
LimitRTTIMESoft=infinity
RootEphemeral=no
OOMScoreAdjust=0
CoredumpFilter=0x23
Nice=0
IOSchedulingClass=2
IOSchedulingPriority=4
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
CPUAffinityFromNUMA=no
NUMAPolicy=n/a
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SyslogLevel=6
SyslogFacility=3
LogLevelMax=-1
LogRateLimitIntervalUSec=0
LogRateLimitBurst=0
SecureBits=0
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lock cap_ipc_owner cap_sys_module cap_sys_chroot cap_sys_ptrace cap_sys_pacct cap_sys_admin cap_sys_boot cap_sys_nice cap_sys_resource cap_sys_time cap_sys_tty_config cap_lease cap_audit_write cap_audit_control cap_setfcap cap_mac_override cap_mac_admin cap_syslog cap_wake_alarm cap_block_suspend cap_audit_read cap_perfmon cap_bpf cap_checkpoint_restore
DynamicUser=no
SetLoginEnvironment=no
RemoveIPC=no
PrivateTmp=yes
PrivateDevices=yes
ProtectClock=no
ProtectKernelTunables=no
ProtectKernelModules=no
ProtectKernelLogs=no
ProtectControlGroups=no
PrivateNetwork=no
PrivateUsers=no
PrivateMounts=no
PrivateIPC=no
ProtectHome=yes
ProtectSystem=full
SameProcessGroup=no
UtmpMode=init
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=2147483646
LockPersonality=no
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
RuntimeDirectoryPreserve=yes
RuntimeDirectoryMode=0755
RuntimeDirectory=phpfpm
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=0755
ConfigurationDirectoryMode=0755
TimeoutCleanUSec=infinity
MemoryDenyWriteExecute=no
RestrictRealtime=no
RestrictSUIDSGID=no
RestrictNamespaces=no
MountAPIVFS=no
KeyringMode=private
ProtectProc=default
ProcSubset=all
ProtectHostname=no
MemoryKSM=no
RootImagePolicy=root=verity+signed+encrypted+unprotected+absent:usr=verity+signed+encrypted+unprotected+absent:home=encrypted+unprotected+absent:srv=encrypted+unprotected+absent:tmp=encrypted+unprotected+absent:var=encrypted+unprotected+absent
MountImagePolicy=root=verity+signed+encrypted+unprotected+absent:usr=verity+signed+encrypted+unprotected+absent:home=encrypted+unprotected+absent:srv=encrypted+unprotected+absent:tmp=encrypted+unprotected+absent:var=encrypted+unprotected+absent
ExtensionImagePolicy=root=verity+signed+encrypted+unprotected+absent:usr=verity+signed+encrypted+unprotected+absent:home=encrypted+unprotected+absent:srv=encrypted+unprotected+absent:tmp=encrypted+unprotected+absent:var=encrypted+unprotected+absent
KillMode=control-group
KillSignal=15
RestartKillSignal=15
FinalKillSignal=9
SendSIGKILL=yes
SendSIGHUP=no
WatchdogSignal=6
Id=phpfpm-grocy.service
Names=phpfpm-grocy.service
Requires=sysinit.target -.mount system-phpfpm.slice
Wants=-.mount
PartOf=phpfpm.target
WantedBy=phpfpm.target
Conflicts=shutdown.target
Before=shutdown.target phpfpm.target
After=grocy-setup.service system-phpfpm.slice sysinit.target systemd-journald.socket -.mount basic.target network.target systemd-tmpfiles-setup.service
RequiresMountsFor=/run/phpfpm
WantsMountsFor=/var/tmp /tmp
Description=PHP FastCGI Process Manager service for pool grocy
LoadState=loaded
ActiveState=active
FreezerState=running
SubState=running
FragmentPath=/etc/systemd/system/phpfpm-grocy.service
UnitFileState=enabled
UnitFilePreset=ignored
StateChangeTimestamp=Tue 2024-11-26 03:22:06 CST
StateChangeTimestampMonotonic=829867445
InactiveExitTimestamp=Tue 2024-11-26 03:22:06 CST
InactiveExitTimestampMonotonic=829773863
ActiveEnterTimestamp=Tue 2024-11-26 03:22:06 CST
ActiveEnterTimestampMonotonic=829867445
ActiveExitTimestamp=Tue 2024-11-26 03:22:06 CST
ActiveExitTimestampMonotonic=829724831
InactiveEnterTimestamp=Tue 2024-11-26 03:22:06 CST
InactiveEnterTimestampMonotonic=829738763
CanStart=yes
CanStop=yes
CanReload=yes
CanIsolate=no
CanClean=runtime
CanFreeze=yes
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
SurviveFinalKillSignal=no
OnSuccessJobMode=fail
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Tue 2024-11-26 03:22:06 CST
ConditionTimestampMonotonic=829770629
AssertTimestamp=Tue 2024-11-26 03:22:06 CST
AssertTimestampMonotonic=829770632
Transient=no
Perpetual=no
StartLimitIntervalUSec=10s
StartLimitBurst=5
StartLimitAction=none
FailureAction=none
SuccessAction=none
InvocationID=19a09388017e407297f5a9634fcf2b0a
CollectMode=inactive
[global]
daemonize = no
error_log = syslog
[grocy]
catch_workers_output = yes
group = grocy
listen = /run/phpfpm/grocy.sock
listen.group = caddy
listen.owner = caddy
php_admin_flag[log_errors] = yes
php_admin_value[error_log] = stderr
pm = dynamic
pm.max_children = 32
pm.max_requests = 500
pm.max_spare_servers = 4
pm.min_spare_servers = 2
pm.start_servers = 2
user = grocy
env[GROCY_CACHE_DIR] = /var/lib/grocy/viewcache
env[GROCY_CONFIG_FILE] = /etc/grocy/config.php
env[GROCY_DB_FILE] = /var/lib/grocy/grocy.db
env[GROCY_PLUGIN_DIR] = /var/lib/grocy/plugins
env[GROCY_STORAGE_DIR] = /var/lib/grocy/storage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment